/
options.go
41 lines (35 loc) · 910 Bytes
/
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package sbProxy
import (
"github.com/asim/go-micro/v3/client"
"github.com/dh1tw/remoteRotator/rotator"
)
func Client(cli client.Client) func(*SbProxy) {
return func(r *SbProxy) {
r.cli = cli
}
}
// DoneCh is a functional option allows you to pass a channel to the proxy object.
// This channel will be closed by this object. It serves as a notification that
// the object can be deleted.
func DoneCh(ch chan struct{}) func(*SbProxy) {
return func(r *SbProxy) {
r.doneCh = ch
}
}
func Name(name string) func(*SbProxy) {
return func(r *SbProxy) {
r.name = name
}
}
func ServiceName(name string) func(*SbProxy) {
return func(r *SbProxy) {
r.serviceName = name
}
}
// EventHandler sets a callback function through which the proxy rotator
// will report Events
func EventHandler(h func(rotator.Rotator, rotator.Heading)) func(*SbProxy) {
return func(r *SbProxy) {
r.eventHandler = h
}
}