Commit Graph

156 Commits

Author SHA1 Message Date
Ivan Kozlovic
c040b4fa50 [FIXED] JetStream: Fail Ack() (and the likes) for AckNone consumer
Resolves #1027

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-08-03 18:48:20 -06:00
Jeremy Saenz
1eb8a22c21 Started implementation of direct gets by subject 2022-08-03 09:50:45 -07:00
Belyakov Sergey
add6c3994b Update js.go
fix nil pointer dereference when jsi is not inited
2022-08-01 12:02:03 +07:00
Deepak Sah
fcc7c44324 Allow setting consumer replicas though options (#1019)
[ADDED] Allow setting consumer replicas though options
2022-07-29 12:07:11 -06:00
Ivan Kozlovic
8b04057ca6 Merge pull request #1023 from nats-io/update_certs
Updated TLS certs, move to Go 1.18, fix code due staticcheck report
2022-07-29 12:03:26 -06:00
Ivan Kozlovic
787e58b7c5 Updated TLS certs, move to Go 1.18, fix code due staticcheck report
Fixed a TLS test that fails on macOS but passes on Linux.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-29 11:35:42 -06:00
Ivan Kozlovic
dcf9b938d5 Merge pull request #1022 from bruth/patch-1
[FIXED] Ephemeral PullConsumer's Fetch() would fail with "no responders"
2022-07-29 11:19:18 -06:00
Byron Ruth
726f0d8fb1 Add guard for pull mode
Signed-off-by: Byron Ruth <b@devel.io>
2022-07-29 13:13:45 -04:00
Byron Ruth
fed719aed1 Use consumer name in subject for ephemeral 2022-07-29 08:46:12 -04:00
Ivan Kozlovic
b22f6cbc82 Add options instead of introducing new DirectGetMsg API.
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-28 19:26:56 -06:00
Ivan Kozlovic
6528169f0d [ADDED] JetStream: DirectGetMsg API
The AllowDirect boolean must be set in the stream configuration.
When that is the case, then all servers (leader and replicas) are
part of a DQ group and can respond to a "DIRECT.GET" request.

The KeyValue store makes use of the direct get when connecting
to a stream with the AllowDirect option.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-25 16:45:30 -06:00
Weida Hong
8a4b9f4d11 Consistent error value of context timeout on subscription Fetch() interface. (#1011)
* Add test case about subscription timeout behavior

* Makes context timeout error behavior consistent.

If user provides context object and context timeout,
always return the timeout error from context.
2022-07-04 04:26:08 -07:00
Byron Ruth
d069d15245 Add additional note to JetStream.PullSubscribe on durable semantics 2022-06-07 13:32:37 -04:00
Byron Ruth
5a648026ad Use native time.Time.Equal method for equality check
Fixes #992
2022-06-07 10:03:14 -04:00
Piotr Piotrowski
fe748b369b Merge pull request #990 from nats-io/stream-info-deleted-details
ADDED: option to fetch deleted details in stream info
2022-06-07 15:33:24 +02:00
Piotr Piotrowski
4a1666cd47 Add option to fetch deleted details in stream info 2022-06-07 11:03:30 +02:00
Derek Collison
5a292d0c21 Merge pull request #989 from nats-io/ordered_mem_r1
Ordered will force R1 and memory storage
2022-06-06 17:02:37 -07:00
Derek Collison
5aa2500353 Ordered will force R1 and memory storage
Signed-off-by: Derek Collison <derek@nats.io>
2022-06-06 08:56:04 -07:00
Piotr Piotrowski
39c636d32f Add support for enhanced stream purge in JetStream 2022-06-06 13:53:25 +02:00
Piotr Piotrowski
ffc3c71d21 Fix sending ack when AckNonePolicy is set 2022-06-02 15:30:49 +02:00
Ivan Kozlovic
9aaf72b01b [ADDED] Stream RePublish and some ConsumerConfig new fields
Namely for pull consumers: ability to override the replica count or storage type:
```
// Generally inherited by parent stream and other markers, now can be configured directly.
Replicas int `json:"num_replicas"`
// Force memory storage.
MemoryStorage bool `json:"mem_storage,omitempty"`
```

For the stream, this new StreamConfig option:
```
// Allow republish of the message after being sequenced and stored.
RePublish *SubjectMapping `json:"republish,omitempty"`
```
Where SubjectMapping is:
```
// SubjectMapping allows a source subject to be mapped to a destination subject for republishing.
type SubjectMapping struct {
	Source      string `json:"src,omitempty"`
	Destination string `json:"dest"`
}
```

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-05-24 19:42:24 -06:00
Phil Pennock
9b8bfefb08 spelling fix & dictionary updates
Fix a spelling mistake which made it through to go docs.

gospel 1.13.0 is now out, and it added features which let us remove some old
words (eg, pluralizations of types we define), but it also errored out on
seeing a comment in .words which used to be acceptable.
So remove comments from .words and introduce .words.readme instead.

We lose the section-introducer comments.  Which is a shame.
2022-05-05 17:28:06 -04:00
Waldemar Quevedo
5be4ec526b js: handle 408 fetch requests pending status
Skip 408 errors thrown to client no wait + expires requests

Signed-off-by: Waldemar Quevedo <wally@nats.io>
2022-05-03 15:58:23 -07:00
Byron Ruth
7ce02bfbb2 Change expected last sequence pub options to pointers
This allows for differentiating between the zero value and whether it was intentionally
set to a sequence of zero.

Signed-off-by: Byron Ruth <b@devel.io>
2022-04-14 08:23:26 -04:00
Ivan Kozlovic
8af932f207 Merge pull request #933 from mfaizanse/backoff_sub_opt
Added BackOff helper method to set backoff through subOpts
2022-04-04 14:26:32 -06:00
Waldemar Quevedo
dd3a012c0f Set async pub ack inflight pending default to 4K, add StallWait option
Signed-off-by: Waldemar Quevedo <wally@nats.io>
2022-03-29 16:22:04 -07:00
Waldemar Quevedo
f658a93098 Add ClientTrace struct for JS tracing
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2022-03-28 22:55:03 -07:00
Muhammad Faizan
f0dcbad53d Added BackOff helper method to set backoff through subOpts 2022-03-22 14:09:28 +01:00
Derek Collison
2a5ee5ff33 Allow JetStream Publish retries iff ErrNoResponders was returned.
This is to avoid small blips from leader changes surfacing to the end application.

Signed-off-by: Derek Collison <derek@nats.io>
2022-03-17 11:38:01 -07:00
Ivan Kozlovic
30ecb5dafd JetStream: revert some change made to ordered consumer
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-03-06 11:35:03 -07:00
Ivan Kozlovic
a68a1faac5 [CHANGED] JS: Do not set MaxAckPending to high value on Subscribe
When calling js.Subscribe() (or equivalent) and the library ended-up
creating the JS consumer, a MaxAckPending was set to a very high
value in some cases. We now let the server pick the default if the
value is not explicitly set by the user.
The NATS subscription pending limits are set in a way to ensure
that the subscription can store at least the max ack pending value.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-03-01 14:32:48 -07:00
Ivan Kozlovic
7d7a4feab6 Remove the capture of pending when having a consumer already exist error
Should be done really only when the library successfully created
the consumer.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-02-09 15:46:31 -07:00
Ivan Kozlovic
cc6c8b1d4a Different approach to address initial pending == 0
This is undoing changes done in PR https://github.com/nats-io/nats.go/pull/901
and makes the changes dicussed in the comments of that PR.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-02-09 14:21:31 -07:00
Ivan Kozlovic
85e8c7f7c6 Updates to KV
Relying on ConsumerInfo.NumPending on create was not realiable
if the NATS subscription exists before (which is normal case)
due to a design in the server that process the add consumer
request and then computes the consumer info (after the consumer
is setup which means it could start to deliver messages).

Changed a bit so that we add a JS consumer without attached
subscription and use internal option to allow a js.Subscribe()
with a bind to existing consumer.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-02-08 17:40:31 -07:00
Derek Collison
6cbe82760f Merge pull request #900 from nats-io/watcher_updates
Updates to KV Watcher.
2022-02-07 17:23:05 -08:00
Derek Collison
16c1c768dc Updates to KV Watcher.
1. If the underlying stream was very busy pending might not go to zero, so snapshot and mark initial state done when received >= init pending or delta == 0
2. When a watcher was cancelled with a context we would not signal to allow and range w.Updates() calls to exit.
3. General flow control checks were timing sensitive after the initial checks, needed to be 2x HB interval always, not just beginning.

Signed-off-by: Derek Collison <derek@nats.io>
2022-02-05 20:17:25 -08:00
Phil Pennock
bf1b00513e Spelling fixes, mostly comments
The new `gospel` tool, <https://github.com/kortschak/gospel>, uses hunspell
libraries but pre-registers as acceptable words every symbol from the Go
source, massively reducing the noise and making comment spell-checking a
tractable problem.  It recently gained support for a `.words` file located in
the same directory as the `go.mod` file, to define local words.  With this, we
can fix real issues too.

This PR reduces the complaints down to 4:
 1. A reference to `syncSubscribers` which I can't figure out
 2. A reference to a `pubArg`
 3. Two references to `splitArgs`.

I made two actual code changes:
 1. Fixing a **non-exported** const type for consistency with all the others:
    `apiStreamList` -> `apiStreamListT`.
 2. Changing an error message to refer to a field which exist

Lots of typo fixes; references to since-renamed fields; etc.

A reference to `PublishAsynMsg` might have been intended to be
`PublishAsyncMsg` but that doesn't exist either, so I removed it.
Similarly, `SubjectIsDelivery` lived briefly but a stale reference was left in
a comment, so I removed that.

To reproduce:

    go install github.com/kortschak/gospel@latest
    gospel .
2022-02-05 21:26:46 -05:00
Ivan Kozlovic
d34c12d8a5 Passed nakDelay as an option to internal ackReply() function
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-01-31 18:48:48 -07:00
Ivan Kozlovic
f1d50b84af Remove NakDelay() option and instead add Msg.NakWithDelay()
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-01-31 18:25:00 -07:00
Ivan Kozlovic
fd2a47640d [ADDED] JetStream: Nak delay and BackOff lists
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-01-31 17:56:08 -07:00
Ivan Kozlovic
63b8e8bcc1 [ADDED] JetStream: UpdateConsumer and new consumer config's options
Namely: MaxRequestBatch, MaxRequestExpires and InactiveThreshold

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-01-31 15:02:55 -07:00
Matthew DeVenny
492c3bd206 Fix activityCheck to handle case when timer has been stopped
Signed-off-by: Matthew DeVenny <matt@boxboat.com>
2021-12-15 14:57:17 -07:00
Waldemar Quevedo
16d26f8e7b js: make js.Subscribe context aware
Can now attach a context to a subscription so that it is
unsubscribed and/or consumer deleted via propagation of
cancellation via parent context.

Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-12-14 13:13:23 -08:00
Bartosz Behring
67333f2fa1 Introducing ErrMsgAlreadyAckd to have more detailed error msg when trying to ack msg that was already acknowledged. 2021-11-14 10:28:36 +01:00
Casper Beyer
3d1af3f44c Fix typo in Bind documentation comments 2021-11-10 14:19:59 +08:00
R.I.Pienaar
2554593026 support tracing JS api calls
Signed-off-by: R.I.Pienaar <rip@devco.net>
2021-10-14 10:17:18 +02:00
Ivan Kozlovic
51d43e46a5 [FIXED] JetStream: ordered consumers handling of auto unsub
If user creates an ordered consumer and uses AutoUnsubscribe()
with the returned subscription, and if the ordered consumer was
reset (due to a gap detection), the library should resend an
UNSUB with adjusted max for the new subscription ID.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2021-10-13 13:59:40 -06:00
R.I.Pienaar
4b5b7cfbc1 add kv and object status functionality
Signed-off-by: R.I.Pienaar <rip@devco.net>
2021-10-12 16:54:44 +02:00
R.I.Pienaar
d7eb0d8f98 ensure get returns a nil and key not found as per spec
Signed-off-by: R.I.Pienaar <rip@devco.net>
2021-10-11 17:12:58 +02:00
Derek Collison
141643a344 [ADDED] KeyValue and ObjectStore support for JetStream.
Also:
- Fixed message reply in PublishMsgAsync
- Ability to seal streams
- Ability for consumer to get message headers only, no msg payload
- GetLastMsg and purgeStream by subject

Signed-off-by: Derek Collison <derek@nats.io>
2021-10-07 16:29:26 -06:00