Skip to content
This repository has been archived by the owner on Jan 21, 2025. It is now read-only.

Commit

Permalink
fix: add max pending ACK to the nats consumer configuration (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfinteligenz authored Nov 16, 2023
1 parent d12f209 commit 6b968c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kre-go/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"os"
"strconv"
"strings"

"github.com/konstellation-io/kre/libs/simplelogger"
Expand Down Expand Up @@ -35,13 +36,19 @@ type ConfigNATS struct {
KeyValueStoreWorkflowName string
KeyValueStoreNodeName string
MongoWriterSubject string
MaxPendingAck int
}

type InfluxDB struct {
URI string
}

func NewConfig(logger *simplelogger.SimpleLogger) Config {
maxPendingAck, err := strconv.Atoi(getOptCfgFromEnv(logger, "KRT_MAX_PENDING_ACK"))
if err != nil {
maxPendingAck = -1
}

return Config{
WorkflowName: getCfgFromEnv(logger, "KRT_WORKFLOW_NAME"),
RuntimeID: getCfgFromEnv(logger, "KRT_RUNTIME_ID"),
Expand All @@ -59,6 +66,7 @@ func NewConfig(logger *simplelogger.SimpleLogger) Config {
KeyValueStoreWorkflowName: getCfgFromEnv(logger, "KRT_NATS_KEY_VALUE_STORE_WORKFLOW"),
KeyValueStoreNodeName: getCfgFromEnv(logger, "KRT_NATS_KEY_VALUE_STORE_NODE"),
MongoWriterSubject: getCfgFromEnv(logger, "KRT_NATS_MONGO_WRITER"),
MaxPendingAck: maxPendingAck,
},
MongoDB: MongoDB{
Address: getCfgFromEnv(logger, "KRT_MONGO_URI"),
Expand Down Expand Up @@ -86,6 +94,7 @@ func getOptCfgFromEnv(logger *simplelogger.SimpleLogger, name string) string {
logger.Infof("The %q env var is missing", name)
return ""
}

return val
}

Expand Down
1 change: 1 addition & 0 deletions kre-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func Start(handlerInit HandlerInit, defaultHandler Handler, handlersOpt ...map[s
nats.Durable(consumerName),
nats.ManualAck(),
nats.AckWait(22*time.Hour),
nats.MaxAckPending(cfg.NATS.MaxPendingAck),
)
if err != nil {
logger.Errorf("Error subscribing to NATS subject %s: %s", subject, err)
Expand Down

0 comments on commit 6b968c6

Please sign in to comment.