MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / New

Function New

pkg/gatewayconfigurationserver/managed/managed.go:55–96  ·  view source on GitHub ↗

New returns a new Server.

(ctx context.Context, c Component, conf ttgc.Config)

Source from the content-addressed store, hash-verified

53
54// New returns a new Server.
55func New(ctx context.Context, c Component, conf ttgc.Config) (*Server, error) {
56 srv := &Server{Component: c}
57 srv.grpc.server = &noopManagedGCSServer{}
58 srv.grpc.wifiProfiles = &noopManagedGatewayWiFiProfileServer{}
59 srv.grpc.ethernetProfiles = &noopManagedGatewayEthernetProfileServer{}
60
61 if conf.Enabled {
62 client, err := ttgc.NewClient(ctx, c, conf)
63 if err != nil {
64 return nil, err
65 }
66 srv.grpc.server = &managedGCSServer{
67 Component: c,
68 client: client,
69 gatewayEUIs: conf.GatewayEUIs,
70 }
71 srv.grpc.wifiProfiles = &managedGatewayWiFiProfileServer{
72 client: client,
73 }
74 srv.grpc.ethernetProfiles = &managedGatewayEthernetProfileServer{
75 client: client,
76 }
77 }
78
79 c.GRPCServer().RegisterUnaryHook(
80 "/ttn.lorawan.v3.ManagedGatewayConfigurationService",
81 rpclog.NamespaceHook,
82 rpclog.UnaryNamespaceHook("gatewayconfigurationserver/managed"),
83 )
84 c.GRPCServer().RegisterUnaryHook(
85 "/ttn.lorawan.v3.ManagedGatewayWiFiProfileConfigurationService",
86 rpclog.NamespaceHook,
87 rpclog.UnaryNamespaceHook("gatewayconfigurationserver/managed"),
88 )
89 c.GRPCServer().RegisterUnaryHook(
90 "/ttn.lorawan.v3.ManagedGatewayEthernetProfileConfigurationService",
91 rpclog.NamespaceHook,
92 rpclog.UnaryNamespaceHook("gatewayconfigurationserver/managed"),
93 )
94
95 return srv, nil
96}
97
98// RegisterServices registers services provided by gcs at s.
99func (s *Server) RegisterServices(grpcServer *grpc.Server) {

Callers 1

NewFunction · 0.92

Calls 4

NewClientFunction · 0.92
UnaryNamespaceHookFunction · 0.92
RegisterUnaryHookMethod · 0.80
GRPCServerMethod · 0.65

Tested by

no test coverage detected