Commit Graph

237 Commits

Author SHA1 Message Date
Ivan Kozlovic
45b7e7725b JetStream: lot of changes
They will be described in the release notes, but gist:

Added:
- `DeliverSubject()` option to configure the deliver subject of a JetStream consumer created by the `js.Subscribe()` call (and variants)
- `BindDeliverSubject()` option to subscribe directly to a JetStream consumer deliver subject (bypassing any lookup or JetStream consumer creation)
- Fields `DeliverGroup` in `ConsumerConfig`, `PushBound` in `ConsumerInfo`. They help making prevent incorrect subscriptions to JetStream consumers
- Field `Last` in `SequencePair`

Changed:
- With a `PullSubscription`, calling `NextMsg()` or `NextMsgWithContext()` will now return `ErrTypeSubscription`. You must use the `Fetch()` API
- If the library created internally a JetStream consumer, the consumer will be deleted on `Unsubscribe()` or when the `Drain()` completes
- Fail multiple instances of a subscription on the same durable push consumer (only one active at a time). Also, consumers now have the concept of `DeliverGroup`, which is the queue group name they are created for. Only queue member from the same group can attach to this consumer, and a non queue subscription cannot attach to it. Note that this requires server v2.3.5
- Attempting to create a queue subscription with a consumer configuration that has idle heartbeats and/or flow control will now result in an error

Fixed:
- Possible lock inversion
- JetStream consumers could be incorrectly deleted on subscription's `Unsubscribe()`

Resolves #785
Resolves #776
Resolves #775
Resolves #748
Resolves #747

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2021-08-15 11:47:32 -06:00
Ivan Kozlovic
c91c1043a0 Fixed issue where JS would change subscription subject
This would cause issues during a reconnect

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2021-08-13 10:59:24 -06:00
Ivan Kozlovic
cfef5e6c50 Reworked PullSubscribe implementation
Use a SyncSubscription instead. The only visible change from the
user is that calling Fetch() after Unsubscribe() returns ErrBadSubscription
instead of timeout or context deadline exceeded, which makes more
sense to me. This is the only test that I had to tweak.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2021-08-09 17:59:00 -06:00
Derek Collison
74d305fc3b Updates based on feedback
Signed-off-by: Derek Collison <derek@nats.io>
2021-08-09 13:49:05 -07:00
Derek Collison
0b3386c62c Remove auto-unsub for now for fetch since it leaks subs in older servers
Signed-off-by: Derek Collison <derek@nats.io>
2021-08-09 13:02:41 -07:00
Derek Collison
bce6f989f5 Changes to avoid lock inversion
Signed-off-by: Derek Collison <derek@nats.io>
2021-08-09 12:53:14 -07:00
Derek Collison
c414086daa Move actual sub back to before consumer based on feedback
Signed-off-by: Derek Collison <derek@nats.io>
2021-08-09 12:48:18 -07:00
Derek Collison
90f007b828 Ordered Consumers
This introduces ordered consumers. They are a convenience over ephemeral, no ack, no redelivery, only deliver things in strict order setups.
We have the swap out when we detect gaps and change out the underlying sub and JetStream consumer, and we process the heartbeats as well, detecting gaps at the end or if a stream or consumer is pulled out from underneath of us.

Signed-off-by: Derek Collison <derek@nats.io>
2021-08-06 13:28:53 -07:00
Jaime Piña
d9b402d7d8 Update godoc 2021-07-14 10:39:34 -07:00
actatum
bb2c206532 Add two new sentinel errors. ErrNoStream and ErrNoConsumer (#760)
* squashed commit, adding sentinel errors ErrStreamNotFound and ErrConsumerNotFound

Co-authored-by: Waldemar Quevedo <waldemar.quevedo@gmail.com>
2021-06-28 12:02:06 -07:00
dtest11
c18fffce02 wrong note on ExpectLastMsgId && DeliverByStartSequencePolicy 2021-06-24 00:45:16 +08:00
dtest11
cd14d488ab fix Misspell on note AckSync func 2021-06-24 00:27:41 +08:00
Jarema
128e565e5c Add utility function for setting domain 2021-06-17 15:24:34 +02:00
Waldemar Quevedo
98dc666a0a js: Add ChanQueueSubscribe for JS
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-06-09 10:06:47 -07:00
Waldemar Quevedo
ba098b9960 Merge pull request #740 from nats-io/js-bind-consumer
js: Add nats.Bind option to disable creating consumers
2021-06-03 19:00:28 -07:00
Waldemar Quevedo
6237e10ee9 js: Add Bind option to Subscribe
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-06-03 17:38:19 -07:00
Matthias Hanel
efed691619 [changed] JetStream function to be a constructor only.
Removded then lookup of account info.
now already existing js.AccountInfo has to be called separately.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-06-01 20:03:24 -04:00
Waldemar Quevedo
6b98b3edeb js: Improvements for push consumers with flow control
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-05-03 17:31:15 -07:00
Ivan Kozlovic
ea036d7532 Merge pull request #710 from wallyqs/godoc-context-example
Add godoc example for JS context functions
2021-05-03 12:42:53 -06:00
Ivan Kozlovic
1667213f01 Merge pull request #724 from nats-io/js_fix_shared_channel
Fixed SubscribeSync that could possibly share channel across 2 subs
2021-04-30 09:15:38 -06:00
Waldemar Quevedo
37f9684092 js: Add sub for PullSubscribe for fetch requests
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-04-29 21:36:09 -07:00
Ivan Kozlovic
92272d3f21 Fixed SubscribeSync that could possibly share channel across 2 subs
Also added missing subscription's lock when setting some fields
at the end of initialization.

Fixed some flappers and missing defers.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2021-04-29 16:18:13 -06:00
Waldemar Quevedo
3f05b6aa47 Add nats.Header type based on http.Header
Currently it is case sensitive and preserves the case
without doing any normalization.

Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-04-27 18:07:59 -07:00
Waldemar Quevedo
5a6cad0ca7 js: Fixes to parallel creation of durable consumers
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-04-21 16:36:55 -07:00
Waldemar Quevedo
1aefcb51d1 js: Fix issue with concurrent queue subscribers creating consumer
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-04-17 10:42:53 -07:00
Waldemar Quevedo
e7b6eda230 Add godoc example for JS context functions
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-04-12 14:00:04 -07:00
Waldemar Quevedo
1645e080ca Add consumer to msg Metadata
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-04-12 12:49:23 -07:00
Waldemar Quevedo
6f01c1e172 js: Add godoc examples for JetStream context
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-04-01 15:12:51 -07:00
Waldemar Quevedo
458d7de338 Merge pull request #696 from nats-io/js-meta-rename
js: Renaming of msg metadata fields
2021-04-01 06:46:28 -07:00
Waldemar Quevedo
a28b16eaa1 js: Renaming of msg metadata fields
Signed-off-by: Waldemar Quevedo <wally@synadia.com>

- Add SequencePair to MsgMetadata

Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-03-31 21:57:50 -07:00
Waldemar Quevedo
f42e6f27d9 js: PubAckFuture as interface
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-03-31 12:14:30 -07:00
Waldemar Quevedo
1b16e34671 js: Add support for FlowControl and Heartbeats
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-03-30 23:52:16 -07:00
Waldemar Quevedo
c43363623d js: Add AckOpts for msg.Ack()
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-03-30 13:27:20 -07:00
Waldemar Quevedo
bd0fb9d1e9 js: Fix ChanSubscribe acting as SubscribeSync
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-03-30 10:32:26 -07:00
Jaime Piña
077cf107c9 Make Durable mandatory for PullSubscribe
nats.Durable is a SubOpt that may be passed to PullSubscribe or other
methods. If a durable name isn't passed to PullSubscribe, then we return
a runtime error.

Instead of returning a runtime error for this case, this change updates
the PullSubscribe method to require a durable name parameter.
2021-03-29 16:35:51 -07:00
Ivan Kozlovic
d9ad37db5c Merge pull request #687 from nats-io/godoc
Update API doc
2021-03-29 15:55:53 -06:00
Derek Collison
f48fc6d498 Only place onto chan when creating it.
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-29 13:40:48 -07:00
Derek Collison
282c8b1fea Remove direct from merge
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-29 13:23:06 -07:00
Derek Collison
67ee642087 Fix for merge
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-29 13:18:11 -07:00
Derek Collison
9df112cc6d Merge branch 'master' into async_pub 2021-03-29 13:13:38 -07:00
Derek Collison
8e7cef1c9e Updates based on PR feedback.
1. Done() -> Ok()
2. Async replies have _INBOX prefix versus custom for permissions.

Signed-off-by: Derek Collison <derek@nats.io>
2021-03-29 12:30:03 -07:00
Jaime Piña
e74a7b1a08 Update API doc 2021-03-29 10:21:01 -07:00
Derek Collison
e0f259ad57 Fixes for error changes
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-27 13:42:07 -07:00
Derek Collison
a1da5ef42f Add ability to do async publish to JetStream.
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-27 11:28:20 -07:00
Waldemar Quevedo
2539a87825 js: remove DirectOnly JS Option
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-03-27 10:46:36 -07:00
Waldemar Quevedo
ff187e9737 js: Use old request style for sub.Fetch(1)
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-03-24 23:59:16 -07:00
Waldemar Quevedo
11e6d91a1a js: Add option to consume from Streams that are mirrors or sourced
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
Signed-off-by: Jaime Piña <jaime@synadia.com>
2021-03-17 21:24:30 -07:00
Waldemar Quevedo
ac8b51a3ab js: Add js.PullSubscribe and sub.Fetch APIs for pull consumers
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-03-17 19:09:54 -07:00
Jaime Piña
4b55d1367f Update JetStreamManager to accept JSOpts 2021-03-11 13:06:24 -08:00
Jaime Piña
127790fcc6 Create jsOpts 2021-03-10 16:01:15 -08:00