From d9fd104484d99e2c01713d258d5cbbe4de522159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Babino?= Date: Wed, 11 Sep 2024 06:05:00 -0300 Subject: [PATCH] add `--redis` flag (#52) add --redis flag --- cmd/service/bidcollect.go | 1 + services/bidcollect/bid-processor.go | 3 ++- services/bidcollect/bidcollector.go | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/service/bidcollect.go b/cmd/service/bidcollect.go index 41d7b1c..d9117ab 100644 --- a/cmd/service/bidcollect.go +++ b/cmd/service/bidcollect.go @@ -128,6 +128,7 @@ var bidCollectCmd = &cobra.Command{ OutDir: outDir, OutputTSV: outputTSV, RedisAddr: redisAddr, + UseRedis: useRedis, } bidCollector, err := bidcollect.NewBidCollector(&opts) diff --git a/services/bidcollect/bid-processor.go b/services/bidcollect/bid-processor.go index 9093d37..c55517c 100644 --- a/services/bidcollect/bid-processor.go +++ b/services/bidcollect/bid-processor.go @@ -27,6 +27,7 @@ type BidProcessorOpts struct { OutDir string OutputTSV bool RedisAddr string + UseRedis bool } type OutFiles struct { @@ -68,7 +69,7 @@ func NewBidProcessor(opts *BidProcessorOpts) (*BidProcessor, error) { c.csvFileEnding = "csv" } - if opts.RedisAddr != "" { + if opts.UseRedis && opts.RedisAddr != "" { c.redisClient = redis.NewClient(&redis.Options{ Addr: opts.RedisAddr, Password: "", // no password set diff --git a/services/bidcollect/bidcollector.go b/services/bidcollect/bidcollector.go index 44aef66..4efac2b 100644 --- a/services/bidcollect/bidcollector.go +++ b/services/bidcollect/bidcollector.go @@ -22,6 +22,7 @@ type BidCollectorOpts struct { OutputTSV bool RedisAddr string + UseRedis bool } type BidCollector struct { @@ -57,6 +58,7 @@ func NewBidCollector(opts *BidCollectorOpts) (c *BidCollector, err error) { OutDir: opts.OutDir, OutputTSV: opts.OutputTSV, RedisAddr: opts.RedisAddr, + UseRedis: opts.UseRedis, }) return c, err }