Skip to content

Commit

Permalink
Make the bouncer retry connections when starting up
Browse files Browse the repository at this point in the history
  • Loading branch information
hslatman committed Nov 12, 2023
1 parent 169cc21 commit 298a569
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 298a569

Please sign in to comment.