MCPcopy
hub / github.com/nats-io/nats.go / WithExpectLastSequenceForSubject

Function WithExpectLastSequenceForSubject

jetstream/jetstream_options.go:654–663  ·  view source on GitHub ↗

WithExpectLastSequenceForSubject sets the sequence and subject for which the last sequence number should be checked. If the last message on a subject has a different sequence number server will reject the message and publish will fail.

(seq uint64, subject string)

Source from the content-addressed store, hash-verified

652// has a different sequence number server will reject the message and publish
653// will fail.
654func WithExpectLastSequenceForSubject(seq uint64, subject string) PublishOpt {
655 return func(opts *pubOpts) error {
656 if subject == "" {
657 return fmt.Errorf("%w: subject cannot be empty", ErrInvalidOption)
658 }
659 opts.lastSubjectSeq = &seq
660 opts.lastSubject = subject
661 return nil
662 }
663}
664
665// WithExpectLastMsgID sets the expected message ID the last message on a stream
666// should have. If the last message has a different message ID server will

Callers 2

TestPublishMsgFunction · 0.92
TestPublishMsgAsyncFunction · 0.92

Calls 1

ErrorfMethod · 0.80

Tested by 2

TestPublishMsgFunction · 0.74
TestPublishMsgAsyncFunction · 0.74