aws / aws/aws-sdk-java-v2

DynamoDB Enhanced Client: Provide JSON Attribute Converter Out of the Box

Aperta
#2,162 8 commenti 30 reazioni 0 assegnatari Vedi su GitHub
dynamodb-enhanced feature-request p2
Lingua principale
Java
Stelle
2.6k
Fork
1k
Merge medio
2g 9h
PR unite (30g)
51

Descrizione

It would be nice if the DynamoDB Enhanced Client provided a JSON `AttributeConverter`, something like the SDK v1's `@DynamoDBTypeConvertedJson`. This seems like such a common use case that it would make sense for the SDK to provide it rather than every consumer of the SDK who needs it having to implement it themselves.

I did take a look at implementing it, e.g. `class JsonAttributeConverter implements AttributeConverter`, but it's proving to be a challenge! I wondered how the SDK v2 was handling generic `AttributeConverters` internally, and I found `class SetAttributeConverter> implements AttributeConverter` ([link](https://github.com/aws/aws-sdk-java-v2/blob/master/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/SetAttributeConverter.java)) which, to be honest, I'm still trying to wrap my head around 😄 . That being said, if you think the `SetAttributeConverter` is a good template for how this proposed `JsonAttributeConverter` would work, and you think this would be good for a first time contribution, I'd be happy to take a shot at it myself!

I suppose one major drawback to providing this out of the box is that I don't see a way for a consumer of the SDK to customize the `ObjectMapper`. Everywhere in the SDK, I just see this is a static field: `private static final ObjectMapper MAPPER = new ObjectMapper();`.

For now, as a workaround, I'm just using a non-parameterized, single-use `AttributeConverter` e.g. `class MyCustomEntityJsonAttributeConverter implements AttributeConverter`, the downside being that I need to create one for each custom entity that I want to be JSON converted.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia leggendo services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/SetAttributeConverter.java e gli usi esistenti dello statico ObjectMapper menzionato nell’issue. Determina come un AttributeConverter JSON generico potrebbe supportare tipi di entità personalizzati e la configurazione del mapper. Il lavoro è completato quando l’enhanced client fornisce il converter integrato senza richiedere un converter non parametrizzato per ogni entità.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
aws, java
Ambito
backend, databases
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.