-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathshim_ttrpc.pb.go
122 lines (107 loc) · 3.36 KB
/
shim_ttrpc.pb.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Code generated by protoc-gen-go-ttrpc. DO NOT EDIT.
// source: shim.proto
package v1
import (
context "context"
ttrpc "github.com/containerd/ttrpc"
)
type ShimService interface {
Metrics(context.Context, *MetricsRequest) (*MetricsResponse, error)
GetStatus(context.Context, *ContainerRequest) (*ContainerStatus, error)
SubscribeStatus(context.Context, *SubscribeStatusRequest, Shim_SubscribeStatusServer) error
}
type Shim_SubscribeStatusServer interface {
Send(*ContainerStatus) error
ttrpc.StreamServer
}
type shimSubscribeStatusServer struct {
ttrpc.StreamServer
}
func (x *shimSubscribeStatusServer) Send(m *ContainerStatus) error {
return x.StreamServer.SendMsg(m)
}
func RegisterShimService(srv *ttrpc.Server, svc ShimService) {
srv.RegisterService("zeropod.shim.v1.Shim", &ttrpc.ServiceDesc{
Methods: map[string]ttrpc.Method{
"Metrics": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
var req MetricsRequest
if err := unmarshal(&req); err != nil {
return nil, err
}
return svc.Metrics(ctx, &req)
},
"GetStatus": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
var req ContainerRequest
if err := unmarshal(&req); err != nil {
return nil, err
}
return svc.GetStatus(ctx, &req)
},
},
Streams: map[string]ttrpc.Stream{
"SubscribeStatus": {
Handler: func(ctx context.Context, stream ttrpc.StreamServer) (interface{}, error) {
m := new(SubscribeStatusRequest)
if err := stream.RecvMsg(m); err != nil {
return nil, err
}
return nil, svc.SubscribeStatus(ctx, m, &shimSubscribeStatusServer{stream})
},
StreamingClient: false,
StreamingServer: true,
},
},
})
}
type ShimClient interface {
Metrics(context.Context, *MetricsRequest) (*MetricsResponse, error)
GetStatus(context.Context, *ContainerRequest) (*ContainerStatus, error)
SubscribeStatus(context.Context, *SubscribeStatusRequest) (Shim_SubscribeStatusClient, error)
}
type shimClient struct {
client *ttrpc.Client
}
func NewShimClient(client *ttrpc.Client) ShimClient {
return &shimClient{
client: client,
}
}
func (c *shimClient) Metrics(ctx context.Context, req *MetricsRequest) (*MetricsResponse, error) {
var resp MetricsResponse
if err := c.client.Call(ctx, "zeropod.shim.v1.Shim", "Metrics", req, &resp); err != nil {
return nil, err
}
return &resp, nil
}
func (c *shimClient) GetStatus(ctx context.Context, req *ContainerRequest) (*ContainerStatus, error) {
var resp ContainerStatus
if err := c.client.Call(ctx, "zeropod.shim.v1.Shim", "GetStatus", req, &resp); err != nil {
return nil, err
}
return &resp, nil
}
func (c *shimClient) SubscribeStatus(ctx context.Context, req *SubscribeStatusRequest) (Shim_SubscribeStatusClient, error) {
stream, err := c.client.NewStream(ctx, &ttrpc.StreamDesc{
StreamingClient: false,
StreamingServer: true,
}, "zeropod.shim.v1.Shim", "SubscribeStatus", req)
if err != nil {
return nil, err
}
x := &shimSubscribeStatusClient{stream}
return x, nil
}
type Shim_SubscribeStatusClient interface {
Recv() (*ContainerStatus, error)
ttrpc.ClientStream
}
type shimSubscribeStatusClient struct {
ttrpc.ClientStream
}
func (x *shimSubscribeStatusClient) Recv() (*ContainerStatus, error) {
m := new(ContainerStatus)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}