spring-cloud-aws icon indicating copy to clipboard operation
spring-cloud-aws copied to clipboard

Expand use of DynamoDB table prefix in auto-configuration

Open acollins4-chwy opened this issue 1 year ago • 7 comments

Type: Feature

Is your feature request related to a problem? Please describe. The resolution to the #725 issue (#726) did a good job of addressing the missing table-prefix property, but it over-indexed on making use of the DynamoDbTemplate more convenient and missed an easy opportunity to expand the influence of this new property.

Describe the solution you'd like I feel like utilizing something like the code below in the DynamoDbAutoConfiguration would optimize the number of auto-configuration opportunities (beyond DynamoDbTemplate):

@ConditionalOnMissingBean
@Bean
public DynamoDbTableNameResolver dynamoDbTableNameResolver(DynamoDbProperties properties) {
  return new DefaultDynamoDbTableNameResolver(properties.getTablePrefix());
}

Describe alternatives you've considered An alternative I considered was calling DynamoDbProperties.getTablePrefix() from inside of a DefaultDynamoDbTableNameResolver, but this does not fit the pattern used for other Spring beans within this project.

Additional context n/a

acollins4-chwy avatar May 30 '23 20:05 acollins4-chwy

Thanks @acollins4-chwy . @MatejNedic @maciejwalkowiak what would be your thoughts.

arunkpatra avatar May 31 '23 05:05 arunkpatra

I am not sure if i get it. You can confiure custom DynamoDbTablenameResolver bean and it will be picked up by auto-config. See: https://github.com/awspring/spring-cloud-aws/blob/main/spring-cloud-aws-autoconfigure/src/main/java/io/awspring/cloud/autoconfigure/dynamodb/DynamoDbAutoConfiguration.java#L120

maciejwalkowiak avatar May 31 '23 10:05 maciejwalkowiak

@maciejwalkowiak, the custom configuration is what I'm aiming to avoid here. It's a minor change, but, if the bean exists here, then no one else needs to make a custom version of it. You see what I mean?

acollins4-chwy avatar May 31 '23 18:05 acollins4-chwy

Hey @acollins4-chwy, this would be breaking change. I agree with @maciejwalkowiak that this can be done manually by creating a custom bean. I don't think we should be this specific for use cases that dont use dynamodbTemplate

MatejNedic avatar Jun 03 '23 13:06 MatejNedic

Hey @MatejNedic. Thanks for the reply. Do you mind explaining what this would break?

acollins4-chwy avatar Jun 06 '23 15:06 acollins4-chwy

the benefit of this change is that the return type of the method is the interface rather than the class, right?

alexanderankin avatar Jul 21 '24 16:07 alexanderankin