Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make RPC timeout configurable #238

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@ type RPCConfig struct {

// Lag threshold determines the threshold for whether the /lag_status endpoint returns OK or not
LagThreshold int64 `mapstructure:"lag-threshold"`

// Timeout for any read request
TimeoutRead time.Duration `mapstructure:"timeout-read"`
}

// DefaultRPCConfig returns a default configuration for the RPC server
Expand Down Expand Up @@ -547,6 +550,8 @@ func DefaultRPCConfig() *RPCConfig {
TLSCertFile: "",
TLSKeyFile: "",
LagThreshold: 300,

TimeoutRead: 10 * time.Second,
}
}

Expand Down
3 changes: 3 additions & 0 deletions config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ tls-key-file = "{{ .RPC.TLSKeyFile }}"
# pprof listen address (https://golang.org/pkg/net/http/pprof)
pprof-laddr = "{{ .RPC.PprofListenAddress }}"

# timeout for any read request
timeout-read = "{{ .RPC.TimeoutRead }}"

#######################################################
### P2P Configuration Options ###
#######################################################
Expand Down
4 changes: 4 additions & 0 deletions internal/rpc/core/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@
cfg.WriteTimeout = conf.RPC.TimeoutBroadcastTxCommit + 1*time.Second
}

if conf.RPC.TimeoutRead > 0 {
cfg.ReadTimeout = conf.RPC.TimeoutRead
}

Check warning on line 248 in internal/rpc/core/env.go

View check run for this annotation

Codecov / codecov/patch

internal/rpc/core/env.go#L246-L248

Added lines #L246 - L248 were not covered by tests

// If the event log is enabled, subscribe to all events published to the
// event bus, and forward them to the event log.
if lg := env.EventLog; lg != nil {
Expand Down
Loading