Skip to content

Commit

Permalink
Merge pull request #81 from Transfa/79-add-configuration-parameters-f…
Browse files Browse the repository at this point in the history
…or-number-of-workers-and-channel-size

79 add configuration parameters for number of workers and channel size
  • Loading branch information
koladev32 authored Jul 6, 2024
2 parents 87698c1 + 379d94c commit 960dbc4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Create Adapter for Redis Integration [#76](https://github.com/Transfa/sendhooks-engine/issues/76)
- Add Data Size and Number of Tries to Payload Sent to Redis Status Stream [#75](https://github.com/Transfa/sendhooks-engine/issues/75)
- Add Configuration Parameters for Number of Workers and Channel Size [#79](https://github.com/Transfa/sendhooks-engine/issues/79)

### Fixed

Expand Down
2 changes: 2 additions & 0 deletions sendhooks/adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion sendhooks/adapter/redis_adapter/redis_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (r *RedisAdapter) Connect() error {
Password: redisPassword,
DB: redisDBInt,
TLSConfig: tlsConfig,
PoolSize: 50,
PoolSize: r.config.NumWorkers,
})

return nil
Expand Down
4 changes: 2 additions & 2 deletions sendhooks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 960dbc4

Please sign in to comment.