From ae03698727f717edc5153920e2c0a66e9850956e Mon Sep 17 00:00:00 2001 From: koladev Date: Sat, 6 Jul 2024 14:30:22 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20add=20new=20config=20params?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sendhooks/adapter/adapter.go | 2 ++ sendhooks/adapter/redis_adapter/redis_adapter.go | 2 +- sendhooks/main.go | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sendhooks/adapter/adapter.go b/sendhooks/adapter/adapter.go index 23b338b..dba6a15 100644 --- a/sendhooks/adapter/adapter.go +++ b/sendhooks/adapter/adapter.go @@ -41,6 +41,8 @@ type Configuration struct { Redis RedisConfig `json:"redis"` SecretHashHeaderName string `json:"secretHashHeaderName"` Broker string `json:"broker"` + NumWorkers int `json:"numWorkers"` + ChannelSize int `json:"channelSize"` } // Adapter defines methods for interacting with different queue systems. diff --git a/sendhooks/adapter/redis_adapter/redis_adapter.go b/sendhooks/adapter/redis_adapter/redis_adapter.go index 2cb6b05..5ae8383 100644 --- a/sendhooks/adapter/redis_adapter/redis_adapter.go +++ b/sendhooks/adapter/redis_adapter/redis_adapter.go @@ -71,7 +71,7 @@ func (r *RedisAdapter) Connect() error { Password: redisPassword, DB: redisDBInt, TLSConfig: tlsConfig, - PoolSize: 50, + PoolSize: r.config.NumWorkers, }) return nil diff --git a/sendhooks/main.go b/sendhooks/main.go index 331ac03..98a0d27 100644 --- a/sendhooks/main.go +++ b/sendhooks/main.go @@ -39,8 +39,8 @@ func main() { } // Define the size of the channel and the number of workers - webhookQueue := make(chan adapter.WebhookPayload, 1000) - numWorkers := 50 + webhookQueue := make(chan adapter.WebhookPayload, conf.ChannelSize) + numWorkers := conf.NumWorkers // Start the worker pool var wg sync.WaitGroup