From 1b79f1941d96ac63a293f88afac7016a201b7a57 Mon Sep 17 00:00:00 2001 From: MitulShah1 Date: Mon, 21 Apr 2025 10:33:44 +0530 Subject: [PATCH] fixed nitpicks --- cassandra/config.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/cassandra/config.go b/cassandra/config.go index 74102716..3732c565 100644 --- a/cassandra/config.go +++ b/cassandra/config.go @@ -36,12 +36,14 @@ type Config struct { // ConfigDefault is the default config var ConfigDefault = Config{ - Hosts: []string{"localhost:9042"}, - Keyspace: "gofiber", - Table: "kv_store", - Consistency: gocql.Quorum, - Reset: false, - Expiration: 10 * time.Minute, + Hosts: []string{"localhost:9042"}, + Keyspace: "gofiber", + Table: "kv_store", + Consistency: gocql.Quorum, + Reset: false, + Expiration: 10 * time.Minute, + MaxRetries: 3, + ConnectTimeout: 5 * time.Second, } // configDefault applies `ConfigDefault` values to a user‑supplied Config. @@ -78,5 +80,13 @@ func configDefault(config ...Config) Config { cfg.Expiration = 0 } + if cfg.MaxRetries == 0 { + cfg.MaxRetries = ConfigDefault.MaxRetries + } + + if cfg.ConnectTimeout == 0 { + cfg.ConnectTimeout = ConfigDefault.ConnectTimeout + } + return cfg }