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

Add "human readable" description for offset in reader logs #893

Merged
merged 1 commit into from May 13, 2022

Conversation

wwade
Copy link
Contributor

@wwade wwade commented Apr 21, 2022

When the reader logs an offset value, if the value is a special value,
i.e. FirstOffset / LastOffset, it will log something like

setting the offset ... from -2 to 20

With this change, it'll say "(first offset)" or "(last offset)",
respectively, for example:

setting the offset ... from (first offset) to 20

reader.go Outdated Show resolved Hide resolved
reader.go Outdated Show resolved Hide resolved
reader.go Outdated Show resolved Hide resolved
When the reader logs an offset value, if the value is a special value,
i.e. FirstOffset / LastOffset, it will log something like

    setting the offset ... from -2 to 20

With this change, it'll say "first offset" or "last offset",
respectively, for example:

    setting the offset ... from first offset to 20

It uses a new `fmt.Formatter` type, `humanOffset`, which seems more
expressive (and performant) that simply converting to a string.

Instead of type-casting offset directly, I added a helper
`toHumanOffset` to avoid other types, e.g. `humanOffset(uint64(1))`.
Copy link
Contributor Author

@wwade wwade left a comment

Choose a reason for hiding this comment

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

Thanks for the review!

reader.go Outdated Show resolved Hide resolved
reader.go Outdated Show resolved Hide resolved
reader.go Outdated Show resolved Hide resolved
Copy link
Contributor

@achille-roussel achille-roussel left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

@achille-roussel achille-roussel merged commit 5a19469 into segmentio:main May 13, 2022
@achille-roussel achille-roussel self-assigned this May 13, 2022
@wwade wwade deleted the describe-offset branch May 13, 2022 18:16
fracasula pushed a commit to fracasula/kafka-go that referenced this pull request May 19, 2022
…#893)

When the reader logs an offset value, if the value is a special value,
i.e. FirstOffset / LastOffset, it will log something like

    setting the offset ... from -2 to 20

With this change, it'll say "first offset" or "last offset",
respectively, for example:

    setting the offset ... from first offset to 20

It uses a new `fmt.Formatter` type, `humanOffset`, which seems more
expressive (and performant) that simply converting to a string.

Instead of type-casting offset directly, I added a helper
`toHumanOffset` to avoid other types, e.g. `humanOffset(uint64(1))`.

Co-authored-by: Wade Carpenter <wwade@users.noreply.github.com>
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.

None yet

2 participants