From b161620b1cc721c3e9beb0811c8f5f51dcf06e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sm=C3=B3=C5=82ka?= Date: Thu, 20 Dec 2018 14:05:01 +0100 Subject: [PATCH] NATS: add default ack wait timeout (#26) * NATS: add default ack wait timeout The lack of default value causes ACK timeout immediately, if not supplied. --- message/infrastructure/nats/subscriber.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/message/infrastructure/nats/subscriber.go b/message/infrastructure/nats/subscriber.go index 231adbbc8..576d1db3f 100644 --- a/message/infrastructure/nats/subscriber.go +++ b/message/infrastructure/nats/subscriber.go @@ -83,15 +83,16 @@ func (c *StreamingSubscriberConfig) setDefaults() { if c.CloseTimeout <= 0 { c.CloseTimeout = time.Second * 30 } + if c.AckWaitTimeout <= 0 { + c.AckWaitTimeout = time.Second * 30 + } c.StanSubscriptionOptions = append( c.StanSubscriptionOptions, stan.SetManualAckMode(), // manual AckMode is required to support acking/nacking by client + stan.AckWait(c.AckWaitTimeout), ) - if c.AckWaitTimeout != 0 { - c.StanSubscriptionOptions = append(c.StanSubscriptionOptions, stan.AckWait(c.AckWaitTimeout)) - } if c.DurableName != "" { c.StanSubscriptionOptions = append(c.StanSubscriptionOptions, stan.DurableName(c.DurableName)) }