-
Notifications
You must be signed in to change notification settings - Fork 53
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] [EXPERIMENTAL] added support for next_by_subj to direct stream api #325
Conversation
[REFACTOR] moved direct API to its own JSM api class
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.
See my latest comment in the ADR regarding what needs to be returned to the user and question about "NATS" direct get specific headers..
nats-base-client/jsmdirect_api.ts
Outdated
} | ||
|
||
get lastSequence(): number { | ||
const v = this.header.get(RepublishedHeaders.JsLastSequence); |
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.
I am not seeing that being set by the server. Where would that come from?
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.
very good catch - this was related to the RepublishedMessageHeaders which is not what this PR is about.
…ce to `Nats-Last-Sequence` as this is a Republished Message Header.
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.
A bit confused on what DirectMsgRequest is, since I don't see how this is used. Also looks like NextMsgRequest is missing a field? (but again, not sure how this is being used).
*/ | ||
export type NextMsgRequest = { | ||
seq: number; | ||
next_by_subj: string; |
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.
I think that NextMsgRequest should also have last_by_subj, which corresponds to the enum below to "LastForMsgRequest"?
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 does, the argument that you can provide for getMessage as a DirectMsgRequest
which is an alias for one of three types LastForMsgRequest
is one of the possible values:
export type DirectMsgRequest =
| SeqMsgRequest
| LastForMsgRequest
| NextMsgRequest;
next_by_subj: string; | ||
}; | ||
|
||
export type DirectMsgRequest = |
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.
Not sure what this is for though... looking at the example below, you are creating the request manually and pass last_by_subj (which is missing in the exported NextMsgRequest object above)..
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.
The API returns a StoredMsg
which is an interface (same as what you can $JS.API.STREAM.MSG.GET.${stream}
. In TypeScript this is typed, as you cannot ack or do anything with these messages.
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.
(typescript is just looking for a type that has the fields defined by the type) it is not cast/it is just something that has that 'shape'.
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.
We followed up on a call and it is clear to me now.
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
[REFACTOR] moved direct API to its own JSM api class