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: add encoders to avrogen #292

Merged
merged 4 commits into from
Aug 20, 2023
Merged

feat: add encoders to avrogen #292

merged 4 commits into from
Aug 20, 2023

Conversation

nrwiersma
Copy link
Member

This PR adds support for generating encoders and the schema to all generated objects.

@nrwiersma nrwiersma self-assigned this Aug 20, 2023
@nrwiersma nrwiersma merged commit 0781a60 into main Aug 20, 2023
2 checks passed
@nrwiersma nrwiersma deleted the enocders branch August 20, 2023 14:56
// Schema returns the schema for {{ .Name }}.
func (o *{{ .Name }}) Schema() avro.Schema {
if o.schema == nil {
o.schema = avro.MustParse(` + "`{{ .Schema }}`" + `)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to avoid parsing the schema whenever we decode a new struct? What is the cost of decoding a stream of events (in my case, more than 10K events per second), then processing and encoding them back? Also, each struct will now have an embedded schema struct, adding some memory overhead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats what this does. It caches the schema that is parsed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cache seems to be in the struct level, so each time a new struct is created will have to parse the schema?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #293

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants