-
Notifications
You must be signed in to change notification settings - Fork 31
/
opts.go
47 lines (40 loc) · 1.2 KB
/
opts.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
package jdocs
import (
"github.com/digital-dream-labs/vector-cloud/internal/token"
"github.com/digital-dream-labs/vector-cloud/internal/util"
)
type options struct {
server bool
socketNameSuffix string
tokener token.Accessor
errListener util.ErrorListener
}
// Option defines an option that can be set on the token server
type Option func(o *options)
// WithServer specifies that an IPC server should be started so other processes
// can request jdocs from this process
func WithServer() Option {
return func(o *options) {
o.server = true
}
}
// WithSocketNameSuffix specifies the (optional) suffix of the socket name
func WithSocketNameSuffix(socketNameSuffix string) Option {
return func(o *options) {
o.socketNameSuffix = socketNameSuffix
}
}
// WithTokener specifies that the given token.Accessor should be used to obtain
// authorization credentials
func WithTokener(value token.Accessor) Option {
return func(o *options) {
o.tokener = value
}
}
// WithErrorListener specifies that the given ErrorListener should be passed errors
// that result from jdoc requests
func WithErrorListener(value util.ErrorListener) Option {
return func(o *options) {
o.errListener = value
}
}