Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Commit 3e6ea71

Browse files
committed
fix: handle zero rpc concurrency gracefully
Warn instead of panicking, so we can re-use configuration between Pro and OSS versions
1 parent 30c786c commit 3e6ea71

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

rpc/config.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515

1616
const (
1717
defaultRPCHost = "localhost:50051"
18+
// Slightly less than default Ruby gRPC server concurrency
19+
defaultRPCConcurrency = 28
1820
)
1921

2022
// ClientHelper provides additional methods to operate gRPC client
@@ -61,7 +63,7 @@ type Config struct {
6163
// NewConfig builds a new config
6264
func NewConfig() Config {
6365
return Config{
64-
Concurrency: 28,
66+
Concurrency: defaultRPCConcurrency,
6567
EnableTLS: false,
6668
TLSVerify: true,
6769
Host: defaultRPCHost,

rpc/rpc.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ func NewController(metrics metrics.Instrumenter, config *Config, l *slog.Logger)
172172
metrics.RegisterGauge(metricsRPCPending, "The number of pending RPC calls")
173173

174174
capacity := config.Concurrency
175+
if capacity <= 0 {
176+
capacity = defaultRPCConcurrency
177+
l.Warn("RPC concurrency must be positive, reverted to the default value")
178+
}
175179
barrier, err := NewFixedSizeBarrier(capacity)
176180

177181
if err != nil {

0 commit comments

Comments
 (0)