-
Notifications
You must be signed in to change notification settings - Fork 8
/
options.go
26 lines (23 loc) · 1.01 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package events
import "github.com/pokt-network/poktroll/pkg/client"
// WithDialer returns a client.EventsQueryClientOption which sets the given dialer on the
// resulting eventsQueryClient when passed to NewEventsQueryClient().
func WithDialer(dialer client.Dialer) client.EventsQueryClientOption {
return func(evtClient client.EventsQueryClient) {
evtClient.(*eventsQueryClient).dialer = dialer
}
}
// WithConnRetryLimit returns an option function which sets the number
// of times the replay client should retry in the event that it encounters
// an error or its connection is interrupted.
// If connRetryLimit is < 0, it will retry indefinitely.
func WithConnRetryLimit[T any](limit int) client.EventsReplayClientOption[T] {
return func(client client.EventsReplayClient[T]) {
// Ignore the zero value because limit may be provided via a partially
// configured config struct (i.e. no retry limit set).
// The default will be used instead.
if limit != 0 {
client.(*replayClient[T]).connRetryLimit = limit
}
}
}