-
-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make DynamoDb Clients Standalone #772
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you probably noticed, tests are failing because autoconfiguration classes need to be updated with correct ConditionalOnBean
s.
Also, each autoconfiguration class needs a separate test class that verifies behavior for cases when beans are not there or classes are not there.
.../src/main/java/io/awspring/cloud/autoconfigure/dynamodb/DynamoDbClientAutoConfiguration.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @driverpt ,
Thanks on PR.
Few changes regarding autoconfiguration classes.
...n/java/io/awspring/cloud/autoconfigure/dynamodb/DynamoDbEnhancedClientAutoConfiguration.java
Outdated
Show resolved
Hide resolved
...rc/main/java/io/awspring/cloud/autoconfigure/dynamodb/DynamoDbTemplateAutoConfiguration.java
Outdated
Show resolved
Hide resolved
.../src/main/java/io/awspring/cloud/autoconfigure/dynamodb/DynamoDbClientAutoConfiguration.java
Outdated
Show resolved
Hide resolved
.../src/main/java/io/awspring/cloud/autoconfigure/dynamodb/DynamoDbClientAutoConfiguration.java
Outdated
Show resolved
Hide resolved
.../src/main/java/io/awspring/cloud/autoconfigure/dynamodb/DynamoDbClientAutoConfiguration.java
Outdated
Show resolved
Hide resolved
@maciejwalkowiak @MatejNedic @tomazfernandes , can you please re-review? Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @driverpt ,
Few more changes and we should be good.
Check docs on @Conditional
why it should be applied to static class rather than the @Bean
method directly.
Also, don't forget to add yourself under author list on top of class :)
return DynamoDbEnhancedAsyncClient.builder().dynamoDbClient(dynamoDbClient).build(); | ||
} | ||
|
||
@ConditionalOnClass(DynamoDbTemplate.class) | ||
@ConditionalOnMissingBean(DynamoDbOperations.class) | ||
@Bean | ||
public DynamoDbTemplate dynamoDBTemplate(DynamoDbProperties properties, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's wrap this into a static class for example:
@ConditionalOnClass(name = "io.awspring.cloud.dynamodb.DynamoDbOperations")
@Configuration(proxyBeanMethods = false)
static class DynamoDBTemplateConfiguration {
@ConditionalOnMissingBean(DynamoDbOperations.class)
@Bean
public DynamoDbTemplate dynamoDBTemplate(DynamoDbProperties properties,
DynamoDbEnhancedClient dynamoDbEnhancedClient, Optional<DynamoDbTableSchemaResolver> tableSchemaResolver,
Optional<DynamoDbTableNameResolver> tableNameResolver) {
DynamoDbTableSchemaResolver tableSchemaRes = tableSchemaResolver
.orElseGet(DefaultDynamoDbTableSchemaResolver::new);
DynamoDbTableNameResolver tableNameRes = tableNameResolver
.orElseGet(() -> new DefaultDynamoDbTableNameResolver(properties.getTablePrefix()));
return new DynamoDbTemplate(dynamoDbEnhancedClient, tableSchemaRes, tableNameRes);
}
}
@ConditionalOnMissingBean | ||
@ConditionalOnClass(DynamoDbEnhancedAsyncClient.class) | ||
@Bean | ||
public DynamoDbEnhancedAsyncClient dynamoDbEnhancedAsyncClient(DynamoDbAsyncClient dynamoDbClient) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same like with DynamoDBTemplateConfiguration
should be done.
@ConditionalOnMissingBean | ||
@ConditionalOnClass(DynamoDbEnhancedClient.class) | ||
@Bean | ||
public DynamoDbEnhancedClient dynamoDbEnhancedClient(DynamoDbClient dynamoDbClient) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same like with DynamoDBTemplateConfiguration
should be done.
Can this be reopened? I have no idea why it was closed |
📢 Type of change
📜 Description
Issue: #768 #769
DynamoDb Clients are now initialized Standalone
💡 Motivation and Context
We do not use Spring Data and just wanted simple DynamoDb Initialization
💚 How did you test it?
Integration Tests
📝 Checklist
🔮 Next steps