Skip to content
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

feat!: No more reflection and customizable logical types #175

Merged
merged 1 commit into from
Jan 27, 2024

Conversation

Chuckame
Copy link
Contributor

@Chuckame Chuckame commented Jan 22, 2024

To remove the reflection needs, I needed to work on the root problem: AvroDescriptor. This feature seems nice, but because of kotlinx serialization plugin, when a field is nullable, then the descriptor is wrapped into a kotlinx-internal class so the AvroDescriptor is not accessible anymore (e.g. we cannot check if descriptor is AvroDescriptor as the avro descriptor is inside a private field now).

Now how to generate custom schemas for logical types without being able of creating custom descriptors ? Just by adding annotations to the descriptor.

Then when we want to generate a schema, we first look at our custom annotations AvroXxxLogicalType and depending on the type (time, uuid, decimal, ...), we generate the according schema.

Finally we end up with the same features, without non-standard workarounds, and with much better performances as there isn't reflection anymore!

Relates to #148

Closes #147

Breaking changes

No more AvroDescriptor. If we really want to keep having an api to access custom schema generation (is it really used ?!), then we could create a new annotation to give the custom schema generator (KISS, really wanting it ??) like @CustomSchema(MySchemaGenerator::class)

@Chuckame Chuckame requested a review from thake January 22, 2024 12:58
@Chuckame Chuckame added this to the Version 2 milestone Jan 22, 2024
@Chuckame Chuckame changed the title feat: No more reflection and customizable logical types feat!: No more reflection and customizable logical types Jan 22, 2024
@Chuckame Chuckame mentioned this pull request Jan 22, 2024
14 tasks
@Chuckame Chuckame changed the base branch from main to main-v2 January 27, 2024 15:34
BREAKING CHANGE: No more `AvroDescriptor` so no more custom schema generation
@Chuckame Chuckame merged commit 17eaf60 into avro-kotlin:main-v2 Jan 27, 2024
1 check passed
@Chuckame Chuckame deleted the reflectionless branch January 27, 2024 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Native image issue
1 participant