-
Notifications
You must be signed in to change notification settings - Fork 23
/
info-service.go
51 lines (42 loc) · 1.55 KB
/
info-service.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
48
49
50
51
package grpc
import (
"context"
"go.uber.org/fx"
"google.golang.org/grpc"
"google.golang.org/protobuf/types/known/emptypb"
infov1 "github.com/fluxninja/aperture/v2/api/gen/proto/go/aperture/info/v1"
"github.com/fluxninja/aperture/v2/pkg/info"
"github.com/fluxninja/aperture/v2/pkg/log"
)
// InfoService is the implementation of the infov1.InfoServiceServer interface.
type InfoService struct {
infov1.UnimplementedInfoServiceServer
}
// Version returns the version of the service.
func (vh *InfoService) Version(ctx context.Context, req *emptypb.Empty) (*infov1.VersionInfo, error) {
log.Trace().Msg("Received request on version info handler")
resp := info.GetVersionInfo()
return resp, nil
}
// Process returns the process info of the service.
func (vh *InfoService) Process(ctx context.Context, req *emptypb.Empty) (*infov1.ProcessInfo, error) {
log.Trace().Msg("Received request on process info handler")
resp := info.GetProcessInfo()
return resp, nil
}
// Host returns the hostname of the service.
func (vh *InfoService) Host(ctx context.Context, req *emptypb.Empty) (*infov1.HostInfo, error) {
log.Trace().Msg("Received request on host info handler")
resp := info.GetHostInfo()
return resp, nil
}
// RegisterInfoServiceIn bundles and annotates parameters.
type RegisterInfoServiceIn struct {
fx.In
Server *grpc.Server `name:"default"`
}
// RegisterInfoService registers the InfoService implementation with the provided grpc server.
func RegisterInfoService(in RegisterInfoServiceIn) {
vh := &InfoService{}
infov1.RegisterInfoServiceServer(in.Server, vh)
}