-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
36 lines (29 loc) · 876 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
package grpcbase
import (
"github.com/go-nacelle/nacelle/v2"
"google.golang.org/grpc"
)
type (
options struct {
tagModifiers []nacelle.TagModifier
serverOptions []grpc.ServerOption
}
// ConfigFunc is a function used to configure an instance of
// a gRPC Server.
ConfigFunc func(*options)
)
// WithTagModifiers applies the given tag modifiers on config load.
func WithTagModifiers(modifiers ...nacelle.TagModifier) ConfigFunc {
return func(o *options) { o.tagModifiers = append(o.tagModifiers, modifiers...) }
}
// WithServerOptions sets gRPC options on the underlying server.
func WithServerOptions(opts ...grpc.ServerOption) ConfigFunc {
return func(o *options) { o.serverOptions = append(o.serverOptions, opts...) }
}
func getOptions(configs []ConfigFunc) *options {
options := &options{}
for _, f := range configs {
f(options)
}
return options
}