Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
js: Fix context usage with sub.Fetch and msg.Ack
The deadline of a context is now used to calculate the time used for `expires` instead of the default `ttl` of the JetStream context which was 5s. This was preventing library users from passing a context with a custom timeout. This also disallows the usage of `context.Background` to make it explicit that `sub.Fetch` has to be used with a context that has a timeout since each fetch request has to include an expire time anyway. In case `context.WithCancel` is used, then a child context with the same duration as the JetStream context default timeout will be created. Also in case msg.Ack it was possible to pass both timeout and a context which would have been ambiguous and only context option being used. Signed-off-by: Waldemar Quevedo <wally@synadia.com>
- Loading branch information
Showing
2 changed files
with
328 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.