Move ack to +ACK, +OK still works

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2020-04-29 15:19:42 -07:00
parent 7d7a9e8f23
commit ae8bc2d22b
2 changed files with 6 additions and 4 deletions

View File

@@ -166,7 +166,9 @@ func (r ReplayPolicy) String() string {
// Ack responses. Note that a nil or no payload is same as AckAck
var (
// Ack
AckAck = []byte(OK) // nil or no payload to ack subject also means ACK
AckAck = []byte("+ACK") // nil or no payload to ack subject also means ACK
AckOK = []byte(OK) // deprecated but +OK meant ack as well.
// Nack
AckNak = []byte("-NAK")
// Progress indicator
@@ -595,7 +597,7 @@ func (o *Consumer) processAck(_ *subscription, _ *client, subject, reply string,
sseq, dseq, dcount, _ := o.ReplyInfo(subject)
switch {
case len(msg) == 0, bytes.Equal(msg, AckAck):
case len(msg) == 0, bytes.Equal(msg, AckAck), bytes.Equal(msg, AckOK):
o.ackMsg(sseq, dseq, dcount)
case bytes.Equal(msg, AckNext):
o.ackMsg(sseq, dseq, dcount)

View File

@@ -157,9 +157,9 @@ func (a *Account) AddStreamWithStore(config *StreamConfig, fsConfig *FileStoreCo
// Create our pubAck here. This will be reused and for +OK will contain JSON
// for stream name and sequence.
longestSeq := strconv.FormatUint(math.MaxUint64, 10)
lpubAck := len(AckAck) + len(cfg.Name) + len("{\"stream\": ,\"seq\": }") + len(longestSeq)
lpubAck := len(OK) + len(cfg.Name) + len("{\"stream\": ,\"seq\": }") + len(longestSeq)
mset.pubAck = make([]byte, 0, lpubAck)
mset.pubAck = append(mset.pubAck, AckAck...)
mset.pubAck = append(mset.pubAck, OK...)
mset.pubAck = append(mset.pubAck, fmt.Sprintf(" {\"stream\": %q, \"seq\": ", cfg.Name)...)
return mset, nil