DynamoDB Enhanced Client: Provide JSON Attribute Converter Out of the Box
- Vorherrschende Sprache
- Java
- Sterne
- 2.6k
- Forks
- 1k
- Ø Merge
- 2 T. 9 Std.
- Gemergte PRs (30 T.)
- 51
Beschreibung
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.
Beitragsleitfaden
Rechercherichtung
Beginne mit dem Lesen von services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/SetAttributeConverter.java und der bestehenden Verwendungen des im Issue erwähnten statischen ObjectMapper. Arbeite heraus, wie ein generischer JSON AttributeConverter benutzerdefinierte Entitätstypen und die Konfiguration des Mappers unterstützen könnte. Als erledigt gilt die Aufgabe, wenn der enhanced client den Converter standardmäßig bereitstellt, ohne dass ein nicht parametrisierter Converter pro Entität erforderlich ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- aws, java
- Bereich
- backend, databases
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100