Skip to content

Commit

Permalink
Enable AttemptToReviveEndpoints option in agent and riot clients
Browse files Browse the repository at this point in the history
  • Loading branch information
aalda committed Apr 8, 2019
1 parent 372ec41 commit 8dee396
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
3 changes: 1 addition & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,7 @@ func (c *HTTPClient) healthCheck(timeout time.Duration) {
// the goroutines execute the health-check HTTP request and sets status
go func(endpointURL string) {

// Run a GET request against QED with a timeout
// TODO it should be a HEAD instead of a GET
// Run a HEAD request against QED with a timeout
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

Expand Down
29 changes: 17 additions & 12 deletions client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,22 +133,27 @@ type Config struct {
// HealthCheckTimeout is the timeout in seconds the healthcheck waits for a response
// from a QED server.
HealthCheckTimeout time.Duration

// AttemptToReviveEndpoints sets if dead endpoints will be marked alive again after a
// round-robin round. This way, they will be picked up in the next try.
AttemptToReviveEndpoints bool
}

// DefaultConfig creates a Config structures with default values.
func DefaultConfig() *Config {
return &Config{
Endpoints: []string{"127.0.0.1:8800"},
APIKey: "my-key",
Insecure: DefaultInsecure,
Timeout: DefaultTimeout,
DialTimeout: DefaultDialTimeout,
HandshakeTimeout: DefaultHandshakeTimeout,
ReadPreference: Primary,
MaxRetries: DefaultMaxRetries,
EnableTopologyDiscovery: DefaultTopologyDiscoveryEnabled,
EnableHealthChecks: DefaultHealthCheckEnabled,
DiscoveryTimeout: DefaultTopologyDiscoveryTimeout,
HealthCheckTimeout: DefaultHealthCheckTimeout,
Endpoints: []string{"127.0.0.1:8800"},
APIKey: "my-key",
Insecure: DefaultInsecure,
Timeout: DefaultTimeout,
DialTimeout: DefaultDialTimeout,
HandshakeTimeout: DefaultHandshakeTimeout,
ReadPreference: Primary,
MaxRetries: DefaultMaxRetries,
EnableTopologyDiscovery: DefaultTopologyDiscoveryEnabled,
EnableHealthChecks: DefaultHealthCheckEnabled,
DiscoveryTimeout: DefaultTopologyDiscoveryTimeout,
HealthCheckTimeout: DefaultHealthCheckTimeout,
AttemptToReviveEndpoints: false,
}
}
1 change: 1 addition & 0 deletions client/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func configToOptions(conf *Config) ([]HTTPClientOptionF, error) {
SetDiscoveryTimeout(conf.DiscoveryTimeout),
SetHealthchecks(conf.EnableHealthChecks),
SetHealthCheckTimeout(conf.HealthCheckTimeout),
SetAttemptToReviveEndpoints(conf.AttemptToReviveEndpoints),
}
if len(conf.Endpoints) > 0 {
options = append(options, SetURLs(conf.Endpoints[0], conf.Endpoints[1:]...))
Expand Down
1 change: 1 addition & 0 deletions gossip/auditor/auditor.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func NewAuditor(conf Config) (*Auditor, error) {
client.SetURLs(conf.QEDUrls[0], conf.QEDUrls[1:]...),
client.SetAPIKey(conf.APIKey),
client.SetReadPreference(client.Any),
client.SetAttemptToReviveEndpoints(true),
)
if err != nil {
return nil, errors.Wrap(err, "Cannot start http client: ")
Expand Down
1 change: 1 addition & 0 deletions gossip/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func NewMonitor(conf *Config) (*Monitor, error) {
client.SetURLs(conf.QEDUrls[0], conf.QEDUrls[1:]...),
client.SetAPIKey(conf.APIKey),
client.SetReadPreference(client.Any),
client.SetAttemptToReviveEndpoints(true),
)
if err != nil {
return nil, errors.Wrap(err, "Cannot start http client: ")
Expand Down
1 change: 1 addition & 0 deletions tests/riot.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ func newAttack(conf Config) {
client.SetURLs(conf.Endpoint[0], conf.Endpoint[1:]...),
client.SetAPIKey(conf.APIKey),
client.SetReadPreference(client.Any),
client.SetAttemptToReviveEndpoints(true),
)

if err != nil {
Expand Down

0 comments on commit 8dee396

Please sign in to comment.