Skip to content

Commit

Permalink
Merge branch 'main' into yzang/add-txs-bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
yzang2019 authored Jul 2, 2024
2 parents ef986ba + fbf3097 commit 8fbeecc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
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 @@ func (env *Environment) StartService(ctx context.Context, conf *config.Config) (
cfg.WriteTimeout = conf.RPC.TimeoutBroadcastTxCommit + 1*time.Second
}

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

// 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

0 comments on commit 8fbeecc

Please sign in to comment.