From 31d9c7f2895634f4398c6d73c53785e97039ccff Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Mon, 28 Jan 2019 08:18:02 +0000 Subject: [PATCH] Rename SuccessAutoAck to AckOnSuccess --- options.go | 8 ++++---- stan.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/options.go b/options.go index 174105f..50fd2d5 100644 --- a/options.go +++ b/options.go @@ -34,9 +34,9 @@ func SubscribeContext(ctx context.Context) broker.SubscribeOption { return setSubscribeOption(subscribeContextKey{}, ctx) } -type successAutoAckKey struct{} +type ackSuccessKey struct{} -// SuccessAutoAck allow to AutoAck messages when handler returns without error -func SuccessAutoAck() broker.SubscribeOption { - return setSubscribeOption(successAutoAckKey{}, true) +// AckOnSuccess allow to AutoAck messages when handler returns without error +func AckOnSuccess() broker.SubscribeOption { + return setSubscribeOption(ackSuccessKey{}, true) } diff --git a/stan.go b/stan.go index e48c6e2..9b36c3b 100644 --- a/stan.go +++ b/stan.go @@ -179,7 +179,7 @@ func (n *stanBroker) Subscribe(topic string, handler broker.Handler, opts ...bro if n.conn == nil { return nil, errors.New("not connected") } - var successAutoAck bool + var ackSuccess bool opt := broker.SubscribeOptions{ AutoAck: true, @@ -208,9 +208,9 @@ func (n *stanBroker) Subscribe(topic string, handler broker.Handler, opts ...bro stanOpts = append(stanOpts, subOpts...) } - if bval, ok := ctx.Value(successAutoAckKey{}).(bool); ok && bval { + if bval, ok := ctx.Value(ackSuccessKey{}).(bool); ok && bval { stanOpts = append(stanOpts, stan.SetManualAckMode()) - successAutoAck = true + ackSuccess = true } bopts := stan.DefaultSubscriptionOptions @@ -233,7 +233,7 @@ func (n *stanBroker) Subscribe(topic string, handler broker.Handler, opts ...bro // execute the handler err := handler(&publication{m: &m, msg: msg, t: msg.Subject}) // if there's no error and success auto ack is enabled ack it - if err == nil && successAutoAck { + if err == nil && ackSuccess { msg.Ack() } }