-
Notifications
You must be signed in to change notification settings - Fork 1
/
services.go
34 lines (28 loc) · 938 Bytes
/
services.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
package grpcandgrpcweb
import (
"google.golang.org/grpc"
"aduu.dev/utils/runmanager"
"aduu.dev/utils/runmanager/runnables/grpcserver"
"aduu.dev/utils/runmanager/runnables/grpcwebproxy"
)
// RegisterGrpcServiceFunc registers a grpc endpoint with the given grpc server.
type RegisterGrpcServiceFunc = func(server *grpc.Server)
// Services creates grpc and grpcweb service functions to use with a runmanager setup.
func Services(grpcEndpoint string, grpcWebEndpoint string,
registerFunc RegisterGrpcServiceFunc) []runmanager.Service {
grpcService := grpcserver.Runnable{
Endpoint: grpcEndpoint,
RegisterGRPCService: registerFunc,
}
return []runmanager.Service{
func(m *runmanager.RunManager) {
grpcService.Run(m)
}, func(m *runmanager.RunManager) {
webService := &grpcwebproxy.GRPCWebService{
GrpcServer: grpcService.GRPCServer,
Address: grpcWebEndpoint,
}
webService.Run(m)
},
}
}