-
Notifications
You must be signed in to change notification settings - Fork 455
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
Set defaults and expose configuration of tchannel timeouts. #2173
Changes from 2 commits
3b46c82
88aee00
df955f1
faa9b18
a4abffe
6163b58
b4301cd
fab5ce2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,6 +157,9 @@ type DBConfiguration struct { | |
// Limits contains configuration for limits that can be applied to M3DB for the purposes | ||
// of applying back-pressure or protecting the db nodes. | ||
Limits Limits `yaml:"limits"` | ||
|
||
// Tchannel exposes tchannel config options. | ||
Tchannel TchannelConfiguration `yaml:"tchannel"` | ||
} | ||
|
||
// InitDefaultsAndValidate initializes all default values and validates the Configuration. | ||
|
@@ -573,3 +576,9 @@ func IsSeedNode(initialCluster []environment.SeedNode, hostID string) bool { | |
|
||
return false | ||
} | ||
|
||
// TchannelConfiguration holds tchannel config options. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
type TchannelConfiguration struct { | ||
MaxIdleTime time.Duration `yaml:"maxIdleTime"` | ||
IdleCheckInterval time.Duration `yaml:"idleCheckInterval"` | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,6 +199,12 @@ var ( | |
SetJitter(true), | ||
) | ||
|
||
// defaultChannelOptions are tchannel channel options defaults. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
defaultChannelOptions = &tchannel.ChannelOptions{ | ||
MaxIdleTime: 5 * time.Minute, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Probably would've opted for 1min max idle time and 1-2 minute idle check interval, just since 1min in this world is a very long time heh. |
||
IdleCheckInterval: 5 * time.Minute, | ||
} | ||
|
||
errNoTopologyInitializerSet = errors.New("no topology initializer set") | ||
errNoReaderIteratorAllocateSet = errors.New("no reader iterator allocator set, encoding not set") | ||
) | ||
|
@@ -312,6 +318,7 @@ func newOptions() *options { | |
opts := &options{ | ||
clockOpts: clock.NewOptions(), | ||
instrumentOpts: instrument.NewOptions(), | ||
channelOptions: defaultChannelOptions, | ||
writeConsistencyLevel: defaultWriteConsistencyLevel, | ||
readConsistencyLevel: defaultReadConsistencyLevel, | ||
bootstrapConsistencyLevel: defaultBootstrapConsistencyLevel, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,7 @@ import ( | |
apachethrift "github.com/apache/thrift/lib/go/thrift" | ||
opentracing "github.com/opentracing/opentracing-go" | ||
"github.com/uber-go/tally" | ||
"github.com/uber/tchannel-go" | ||
"go.etcd.io/etcd/embed" | ||
"go.uber.org/zap" | ||
) | ||
|
@@ -599,6 +600,10 @@ func Run(runOpts RunOptions) { | |
// SetDatabase() once we've initialized it. | ||
service = ttnode.NewService(nil, ttopts) | ||
) | ||
if cfg.Tchannel.MaxIdleTime > 0 && cfg.Tchannel.IdleCheckInterval > 0 { | ||
tchannelOpts.MaxIdleTime = cfg.Tchannel.MaxIdleTime | ||
tchannelOpts.IdleCheckInterval = cfg.Tchannel.IdleCheckInterval | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Does this need to check that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The check interval can be independent of the max idle time. |
||
} | ||
tchannelthriftNodeClose, err := ttnode.NewServer(service, | ||
cfg.ListenAddress, contextPool, tchannelOpts).ListenAndServe() | ||
if err != nil { | ||
|
@@ -694,7 +699,7 @@ func Run(runOpts RunOptions) { | |
|
||
origin := topology.NewHost(hostID, "") | ||
m3dbClient, err := newAdminClient( | ||
cfg.Client, iopts, syncCfg.TopologyInitializer, runtimeOptsMgr, | ||
cfg.Client, iopts, tchannelOpts, syncCfg.TopologyInitializer, runtimeOptsMgr, | ||
origin, protoEnabled, schemaRegistry, syncCfg.KVStore, logger) | ||
if err != nil { | ||
logger.Fatal("could not create m3db client", zap.Error(err)) | ||
|
@@ -729,7 +734,7 @@ func Run(runOpts RunOptions) { | |
// Guaranteed to not be nil if repair is enabled by config validation. | ||
clientCfg := *cluster.Client | ||
clusterClient, err := newAdminClient( | ||
clientCfg, iopts, topologyInitializer, runtimeOptsMgr, | ||
clientCfg, iopts, tchannelOpts, topologyInitializer, runtimeOptsMgr, | ||
origin, protoEnabled, schemaRegistry, syncCfg.KVStore, logger) | ||
if err != nil { | ||
logger.Fatal( | ||
|
@@ -1544,6 +1549,7 @@ func withEncodingAndPoolingOptions( | |
func newAdminClient( | ||
config client.Configuration, | ||
iopts instrument.Options, | ||
tchannelOpts *tchannel.ChannelOptions, | ||
topologyInitializer topology.Initializer, | ||
runtimeOptsMgr m3dbruntime.OptionsManager, | ||
origin topology.Host, | ||
|
@@ -1564,6 +1570,9 @@ func newAdminClient( | |
SetMetricsScope(iopts.MetricsScope().SubScope("m3dbclient")), | ||
TopologyInitializer: topologyInitializer, | ||
}, | ||
func(opts client.AdminOptions) client.AdminOptions { | ||
return opts.SetChannelOptions(tchannelOpts).(client.AdminOptions) | ||
}, | ||
func(opts client.AdminOptions) client.AdminOptions { | ||
return opts.SetRuntimeOptionsManager(runtimeOptsMgr).(client.AdminOptions) | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
TChannel
Would it also be better to make this a pointer to be able to more easily tell when it's not been set and avoid default values? Looks like 0s get filtered out later but may be an option?