-
Notifications
You must be signed in to change notification settings - Fork 717
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
Improve jetstream
documentation
#1532
Conversation
Signed-off-by: Piotr Piotrowski <[email protected]>
Signed-off-by: Piotr Piotrowski <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is huge improvement for the docs!
Some comments added.
jetstream/consumer_config.go
Outdated
OptStartTime *time.Time `json:"opt_start_time,omitempty"` | ||
ReplayPolicy ReplayPolicy `json:"replay_policy"` | ||
// FilterSubjects is a set of subjects that overlap with the subjects | ||
// bound to the stream to filter delivered messages. Requires |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same point on overlap as before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
jetstream/jetstream.go
Outdated
// Consumer interface is returned, serving as a hook to operate on a consumer (e.g. fetch messages) | ||
|
||
// CreateConsumer creates a consumer on a given stream with given | ||
// config. If consumer already exists, ErrConsumerExists is returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will not return error if consumer already exists, but the config is exactly the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Co-authored-by: Tomasz Pietrek <[email protected]>
Co-authored-by: Tomasz Pietrek <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really great effort
jetstream/consumer.go
Outdated
FetchNoWait(batch int) (MessageBatch, error) | ||
// Consume can be used to continuously receive messages and handle them with the provided callback function | ||
|
||
// Consume can be used to continuously receive messages and handle them |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under what circumstances will it not be continuous? Similar question on the description of the struct itself and others mentioning continuous consumption.
I don't know this API so maybe asking dumb questions sorry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is I think not worded properly. Consume
and Messages
are continuous and will never stop with exception of a few conditions:
- user calls Stop/Drain
- consumer deleted
- consumer not found after server reconnect (after multiple retries)
That's true for standard pull consumer anyway, for ordered consumer "consumer deleted" is not terminal - we just create a new one. So I don't think this is something that I would put as a comment on the Consumer
interface.
I will reword the descriptions to make sure it's clear that those methods are intentionally endless.
jetstream/consumer.go
Outdated
// Next is used to retrieve the next message from the stream. | ||
// This method will block until the message is retrieved or timeout is reached. | ||
|
||
// Next is used to retrieve the next message from the stream. This |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from the consumer
... I know its technically fetching from the stream but saying its from the consumer makes it clear it is subject to all the filtering and policies configured there maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
jetstream/consumer_config.go
Outdated
// message, including its sequence numbers and timestamp. | ||
Delivered SequenceInfo `json:"delivered"` | ||
|
||
// AckFloor tracks the highest sequence number of a message that has |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indicates the message before the first unacknowledged message - maybe something like that? It is confusing for sure
jetstream/stream_config.go
Outdated
Deleted []uint64 `json:"deleted"` | ||
|
||
// NumDeleted is the number of messages that have been removed from the | ||
// stream. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is a bit more nuance than just have been removed
. It's about gaps so if the stream has 1,10,11 deleted is 9, but if the stream has 10,11 deleted is 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's another weird tough thing to explain concisely...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to:
// NumDeleted is the number of messages that have been removed from the
// stream. Only deleted messages causing a gap in stream sequence numbers
// are counted. Messages deleted at the beginning or end of the stream
// are not counted.
jetstream/stream_config.go
Outdated
// messages on. | ||
NumSubjects uint64 `json:"num_subjects"` | ||
|
||
// Subjects is a list of subjects the stream has received messages on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list of subjects and message counts per subject.
If asked do you do paged requests to get them all behind the scenes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, since recently I do (it was actually missing in the new API)
Thank you so much for this, it is going to make adoption of NATS easier for teams and reinforces my faith in the team moving forward! |
48e18b2
to
d5135d8
Compare
Signed-off-by: Piotr Piotrowski <[email protected]>
d5135d8
to
77ba6cc
Compare
Thanks for the detailed reviews. I believe I address all of the comments (still not sure what to do with the links: #1532 (comment)). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amazing, some minor nits else LGTM
@@ -0,0 +1,89 @@ | |||
package jetstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs copyright blurb
@@ -0,0 +1,26 @@ | |||
package jetstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copyright
Signed-off-by: Piotr Piotrowski <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Great effort!
I just wanted to mention, these doc additions are super helpful, thanks! |
This is the first part of improving
jetstream
package documentation.This PR updates documantation for core jetstream (no KV or Object Store), by expanding docs to struct fields, as well as having more detailed documentation on public methods and interfaces.
What will be added in subsequent PRs:
Signed-off-by: Piotr Piotrowski [email protected]