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

[chore][pkg/stanza] refactor: introduce emit.Token struct #36260

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

andrzej-stencel
Copy link
Member

This makes the code clearer by encapsulating the token's body and attributes in a single structure. It should make future change clearer when the emit callback will be changed to accept a collection of tokens as opposed to a single token.

The Sink type could use some refactoring as well, but I'm not doing it here to keep the changes to the minimum for clarity and ease of code review.

This makes the code clearer by encapsulating the token's body and attributes in a single structure.
It should make future change clearer when the emit callback will be changed to accept a collection of tokens as opposed to a single token.
The Sink type could use some refactoring as well,
but I'm not doing it here to keep the changes to the minimum
for clarity and ease of code review.
@@ -7,4 +7,16 @@ import (
"context"
)

type Callback func(ctx context.Context, token []byte, attrs map[string]any) error
type Callback func(ctx context.Context, token Token) error
Copy link
Member Author

@andrzej-stencel andrzej-stencel Nov 7, 2024

Choose a reason for hiding this comment

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

I considered if the token parameter should be a pointer *Token, but since the Token struct only contains two "reference type" members, a slice and a map, I thought it wouldn't help much to create a pointer to a struct that contains two pointers? 🤔

Please let me know if I'm missing anything. My Go language skills are still limited.

Copy link
Member

Choose a reason for hiding this comment

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

Seems reasonable to me. This is technically a breaking change, but I think it obscure enough code that we should only note it as a changelog.

Copy link
Member Author

@andrzej-stencel andrzej-stencel Nov 7, 2024

Choose a reason for hiding this comment

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

Right, thanks for pointing this out. I'll add an API changelog entry for this.

@andrzej-stencel
Copy link
Member Author

I only ran Stanza tests before pushing the code, but need to also change other parts of Contrib code 🤦 Changing this to draft until I update the other codes.

@andrzej-stencel andrzej-stencel marked this pull request as draft November 7, 2024 15:49
But skip the generated files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants