-
Notifications
You must be signed in to change notification settings - Fork 11
/
option.go
79 lines (67 loc) · 1.65 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Copyright (c) 2019 Zenichi Amano
*
* This file is part of go-push-receiver, which is MIT licensed.
* See http://opensource.org/licenses/MIT
*/
package pushreceiver
import (
"crypto/tls"
"net"
)
// ClientOption type
type ClientOption func(*Client)
// WithLogger is logger setter
func WithLogger(logger logger) ClientOption {
return func(client *Client) {
client.log = internalLog{logger}
}
}
// WithCreds is credentials setter
func WithCreds(creds *FCMCredentials) ClientOption {
return func(client *Client) {
client.creds = creds
}
}
// WithReceivedPersistentID is received persistentId list setter
func WithReceivedPersistentID(ids []string) ClientOption {
return func(client *Client) {
client.receivedPersistentID = ids
}
}
// WithHTTPClient is http.Client setter
func WithHTTPClient(c httpClient) ClientOption {
return func(client *Client) {
client.httpClient = c
}
}
// WithTLSConfig is tls.Config setter
func WithTLSConfig(c *tls.Config) ClientOption {
return func(client *Client) {
client.tlsConfig = c
}
}
// WithBackoff is Backoff setter
func WithBackoff(b *Backoff) ClientOption {
return func(client *Client) {
client.backoff = b
}
}
// WithHeartbeat is Heartbeat setter
func WithHeartbeat(options ...HeartbeatOption) ClientOption {
return func(client *Client) {
client.heartbeat = newHeartbeat(options...)
}
}
// WithDialer is net.Dialer setter
func WithDialer(dialer *net.Dialer) ClientOption {
return func(client *Client) {
client.dialer = dialer
}
}
// WithRetry configures whether to retry when an error occurs.
func WithRetry(retry bool) ClientOption {
return func(client *Client) {
client.retryDisabled = !retry
}
}