-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathoption.go
36 lines (30 loc) · 907 Bytes
/
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
package grpcserver
import (
"google.golang.org/grpc"
)
// Options are options for the [GrpcServerFactory] implementations.
type Options struct {
ServerOptions []grpc.ServerOption
Reflection bool
}
// DefaultGrpcServerOptions are the default options used in the [DefaultGrpcServerFactory].
func DefaultGrpcServerOptions() Options {
return Options{
ServerOptions: []grpc.ServerOption{},
Reflection: false,
}
}
// GrpcServerOption are functional options for the [GrpcServerFactory] implementations.
type GrpcServerOption func(o *Options)
// WithServerOptions is used to configure a list of [grpc.ServerOption].
func WithServerOptions(s ...grpc.ServerOption) GrpcServerOption {
return func(o *Options) {
o.ServerOptions = s
}
}
// WithReflection is used to enable gRPC server reflection.
func WithReflection(r bool) GrpcServerOption {
return func(o *Options) {
o.Reflection = r
}
}