func mergeDefaultOptions(opts *Options) *Options { def := defaultOptions() if opts == nil { return def } if opts.Logger == nil { opts.Logger = def.Logger } opts.SuspicionTimeout = util.SelectDuration(opts.SuspicionTimeout, def.SuspicionTimeout) opts.MinProtocolPeriod = util.SelectDuration(opts.MinProtocolPeriod, def.MinProtocolPeriod) opts.RollupMaxUpdates = util.SelectInt(opts.RollupMaxUpdates, def.RollupMaxUpdates) opts.RollupFlushInterval = util.SelectDuration(opts.RollupFlushInterval, def.RollupFlushInterval) opts.JoinTimeout = util.SelectDuration(opts.JoinTimeout, def.JoinTimeout) opts.PingTimeout = util.SelectDuration(opts.PingTimeout, def.PingTimeout) opts.PingRequestTimeout = util.SelectDuration(opts.PingRequestTimeout, def.PingRequestTimeout) opts.PingRequestSize = util.SelectInt(opts.PingRequestSize, def.PingRequestSize) return opts }
func (f *Forwarder) mergeDefaultOptions(opts *Options) *Options { def := f.defaultOptions() if opts == nil { return def } var merged Options merged.MaxRetries = util.SelectInt(opts.MaxRetries, def.MaxRetries) merged.Timeout = util.SelectDuration(opts.Timeout, def.Timeout) merged.RerouteRetries = opts.RerouteRetries merged.RetrySchedule = opts.RetrySchedule if opts.RetrySchedule == nil { merged.RetrySchedule = def.RetrySchedule } merged.Logger = opts.Logger if opts.Logger == nil { merged.Logger = def.Logger } return &merged }
// newJoinSender returns a new JoinSender to join a cluster with func newJoinSender(node *Node, opts *joinOpts) (*joinSender, error) { if opts == nil { opts = &joinOpts{} } if len(node.bootstrapHosts) == 0 { return nil, errors.New("bootstrap hosts cannot be empty") } js := &joinSender{ node: node, } js.potentialNodes = js.CollectPotentialNodes(nil) js.timeout = util.SelectDuration(opts.timeout, defaultJoinTimeout) js.maxJoinDuration = util.SelectDuration(opts.maxJoinDuration, defaultMaxJoinDuration) js.parallelismFactor = util.SelectInt(opts.parallelismFactor, defaultParallelismFactor) js.size = util.SelectInt(opts.size, defaultJoinSize) js.size = util.Min(js.size, len(js.potentialNodes)) return js, nil }