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)
| 652 | // has a different sequence number server will reject the message and publish |
| 653 | // will fail. |
| 654 | func 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 |