-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathproto.go
More file actions
33 lines (28 loc) · 851 Bytes
/
proto.go
File metadata and controls
33 lines (28 loc) · 851 Bytes
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
package lang
import (
"context"
"github.com/freeconf/gnmi"
"github.com/freeconf/lang/pb"
"github.com/freeconf/restconf"
"github.com/freeconf/restconf/device"
)
type ProtoService struct {
pb.UnimplementedProtoServer
d *Driver
}
func (s *ProtoService) RestconfServer(ctx context.Context, req *pb.RestconfServerRequest) (*pb.RestconfServerResponse, error) {
d := s.d.handles.Require(req.DeviceHnd).(*device.Local)
server := restconf.NewServer(d)
resp := pb.RestconfServerResponse{
ServerHnd: s.d.handles.Put(server),
}
return &resp, nil
}
func (s *ProtoService) GnmiServer(ctx context.Context, req *pb.GnmiServerRequest) (*pb.GnmiServerResponse, error) {
d := s.d.handles.Require(req.DeviceHnd).(*device.Local)
server := gnmi.NewServer(d)
resp := pb.GnmiServerResponse{
ServerHnd: s.d.handles.Put(server),
}
return &resp, nil
}