Skip to content

Commit

Permalink
connCheckTimeout as flag
Browse files Browse the repository at this point in the history
  • Loading branch information
henrod committed Jul 5, 2018
1 parent e0b2331 commit e66a7ae
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
10 changes: 6 additions & 4 deletions cmd/agent/app/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package app
import (
"fmt"
"net/http"
"time"

"github.com/apache/thrift/lib/go/thrift"
"github.com/pkg/errors"
Expand All @@ -36,10 +37,11 @@ import (
)

const (
defaultQueueSize = 1000
defaultMaxPacketSize = 65000
defaultServerWorkers = 10
defaultMinPeers = 3
defaultQueueSize = 1000
defaultMaxPacketSize = 65000
defaultServerWorkers = 10
defaultMinPeers = 3
defaultConnCheckTimeout = 250 * time.Millisecond

defaultHTTPServerHostPort = ":5778"

Expand Down
6 changes: 6 additions & 0 deletions cmd/agent/app/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const (
collectorHostPort = "collector.host-port"
httpServerHostPort = "http-server.host-port"
discoveryMinPeers = "discovery.min-peers"
discoveryConnCheckTimeout = "discovery.conn-check-timeout"
)

var defaultProcessors = []struct {
Expand Down Expand Up @@ -63,6 +64,10 @@ func AddFlags(flags *flag.FlagSet) {
discoveryMinPeers,
defaultMinPeers,
"if using service discovery, the min number of connections to maintain to the backend")
flags.Duration(
discoveryConnCheckTimeout,
defaultConnCheckTimeout,
"sets the timeout used when establishing new connections")
}

// InitFromViper initializes Builder with properties retrieved from Viper.
Expand All @@ -84,5 +89,6 @@ func (b *Builder) InitFromViper(v *viper.Viper) *Builder {
}
b.HTTPServer.HostPort = v.GetString(httpServerHostPort)
b.DiscoveryMinPeers = v.GetInt(discoveryMinPeers)
b.ConnCheckTimeout = v.GetDuration(discoveryConnCheckTimeout)
return b
}
9 changes: 8 additions & 1 deletion cmd/agent/app/reporter/tchannel/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package tchannel

import (
"time"

"github.com/pkg/errors"
"github.com/uber/jaeger-lib/metrics"
"github.com/uber/tchannel-go"
Expand Down Expand Up @@ -44,6 +46,9 @@ type Builder struct {
// responds to.
CollectorServiceName string `yaml:"collectorServiceName"`

// ConnCheckTimeout is the timeout used when establishing new connections.
ConnCheckTimeout time.Duration

discoverer discovery.Discoverer
notifier discovery.Notifier
channel *tchannel.Channel
Expand Down Expand Up @@ -92,7 +97,9 @@ func (b *Builder) enableDiscovery(channel *tchannel.Channel, logger *zap.Logger)
peers := subCh.Peers()
return peerlistmgr.New(peers, b.discoverer, b.notifier,
peerlistmgr.Options.MinPeers(defaultInt(b.DiscoveryMinPeers, defaultMinPeers)),
peerlistmgr.Options.Logger(logger))
peerlistmgr.Options.Logger(logger),
peerlistmgr.Options.ConnCheckTimeout(b.ConnCheckTimeout),
)
}

// CreateReporter creates the TChannel-based Reporter
Expand Down

0 comments on commit e66a7ae

Please sign in to comment.