-
Notifications
You must be signed in to change notification settings - Fork 23
/
provide.go
34 lines (28 loc) · 967 Bytes
/
provide.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 controlpoints
import (
"go.uber.org/fx"
"google.golang.org/grpc"
flowcontrolpointsv1 "github.com/fluxninja/aperture/v2/api/gen/proto/go/aperture/flowcontrol/controlpoints/v1"
"github.com/fluxninja/aperture/v2/pkg/log"
"github.com/fluxninja/aperture/v2/pkg/net/grpcgateway"
)
// Module provides preview handler and registers the service.
func Module() fx.Option {
return fx.Options(
fx.Provide(NewHandler),
grpcgateway.RegisterHandler{Handler: flowcontrolpointsv1.RegisterFlowControlPointsServiceHandlerFromEndpoint}.Annotate(),
fx.Invoke(Register),
)
}
// RegisterIn bundles and annotates parameters.
type RegisterIn struct {
fx.In
Server *grpc.Server `name:"default"`
Handler *Handler
}
// Register registers the handler on grpc.Server.
func Register(in RegisterIn) error {
flowcontrolpointsv1.RegisterFlowControlPointsServiceServer(in.Server, in.Handler)
log.Info().Msg("FlowControl ControlPoints handler registered")
return nil
}