-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathclient_option.go
39 lines (32 loc) · 943 Bytes
/
client_option.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
27
28
29
30
31
32
33
34
35
36
37
38
39
package gue
import (
"go.opentelemetry.io/otel/metric"
"github.com/vgarvardt/gue/v5/adapter"
)
// ClientOption defines a type that allows to set client properties during the build-time.
type ClientOption func(*Client)
// WithClientLogger sets Logger implementation to client.
func WithClientLogger(logger adapter.Logger) ClientOption {
return func(c *Client) {
c.logger = logger
}
}
// WithClientID sets client ID for easier identification in logs.
func WithClientID(id string) ClientOption {
return func(c *Client) {
c.id = id
}
}
// WithClientBackoff sets backoff implementation that will be applied to errored jobs
// within current client session.
func WithClientBackoff(backoff Backoff) ClientOption {
return func(c *Client) {
c.backoff = backoff
}
}
// WithClientMeter sets metric.Meter instance to the client.
func WithClientMeter(meter metric.Meter) ClientOption {
return func(c *Client) {
c.meter = meter
}
}