Skip to content

Commit

Permalink
Merge pull request #27 from hslatman/retry-initial-connection
Browse files Browse the repository at this point in the history
Make the bouncer retry connections when starting up
  • Loading branch information
hslatman authored Nov 12, 2023
2 parents 169cc21 + 298a569 commit 50f68af
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions internal/bouncer/bouncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ func New(apiKey, apiURL, tickerInterval string, logger *zap.Logger) (*Bouncer, e
insecureSkipVerify := false
return &Bouncer{
streamingBouncer: &csbouncer.StreamBouncer{
APIKey: apiKey,
APIUrl: apiURL,
InsecureSkipVerify: &insecureSkipVerify,
TickerInterval: tickerInterval,
UserAgent: userAgent,
APIKey: apiKey,
APIUrl: apiURL,
InsecureSkipVerify: &insecureSkipVerify,
TickerInterval: tickerInterval,
UserAgent: userAgent,
RetryInitialConnect: true,
},
liveBouncer: &csbouncer.LiveBouncer{
APIKey: apiKey,
Expand All @@ -65,15 +66,16 @@ func New(apiKey, apiURL, tickerInterval string, logger *zap.Logger) (*Bouncer, e
}, nil
}

// EnableStreaming enables usage of the StreamBouncer (instead of the LiveBouncer)
// EnableStreaming enables usage of the StreamBouncer (instead of the LiveBouncer).
func (b *Bouncer) EnableStreaming() {
b.useStreamingBouncer = true
}

// EnableHardFails will make the bouncer fail hard on (connection) errors
// when contacting the CrowdSec Local API
// when contacting the CrowdSec Local API.
func (b *Bouncer) EnableHardFails() {
b.shouldFailHard = true
b.streamingBouncer.RetryInitialConnect = false
}

// Init initializes the Bouncer
Expand Down

0 comments on commit 50f68af

Please sign in to comment.