forked from poseidon/matchbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
groups.go
40 lines (32 loc) · 1.23 KB
/
groups.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
package rpc
import (
"golang.org/x/net/context"
"github.com/coreos/matchbox/matchbox/rpc/rpcpb"
"github.com/coreos/matchbox/matchbox/server"
pb "github.com/coreos/matchbox/matchbox/server/serverpb"
)
// groupServer takes a matchbox Server and implements a gRPC GroupsServer.
type groupServer struct {
srv server.Server
}
func newGroupServer(s server.Server) rpcpb.GroupsServer {
return &groupServer{
srv: s,
}
}
func (s *groupServer) GroupPut(ctx context.Context, req *pb.GroupPutRequest) (*pb.GroupPutResponse, error) {
_, err := s.srv.GroupPut(ctx, req)
return &pb.GroupPutResponse{}, grpcError(err)
}
func (s *groupServer) GroupGet(ctx context.Context, req *pb.GroupGetRequest) (*pb.GroupGetResponse, error) {
group, err := s.srv.GroupGet(ctx, req)
return &pb.GroupGetResponse{Group: group}, grpcError(err)
}
func (s *groupServer) GroupDelete(ctx context.Context, req *pb.GroupDeleteRequest) (*pb.GroupDeleteResponse, error) {
err := s.srv.GroupDelete(ctx, req)
return &pb.GroupDeleteResponse{}, grpcError(err)
}
func (s *groupServer) GroupList(ctx context.Context, req *pb.GroupListRequest) (*pb.GroupListResponse, error) {
groups, err := s.srv.GroupList(ctx, req)
return &pb.GroupListResponse{Groups: groups}, grpcError(err)
}