Passed
Push — master ( 197452...9d95d2 )
by
unknown
03:10 queued 15s
created

basev1.*healthClient.Watch   A

Complexity

Conditions 4

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 11
nop 3
dl 0
loc 14
rs 9.85
c 0
b 0
f 0
1
// Copyright 2015 The gRPC Authors
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
// The canonical version of this proto can be found at
16
// https://github.com/grpc/grpc-proto/blob/master/grpc/health/v1/health.proto
17
18
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
19
// versions:
20
// - protoc-gen-go-grpc v1.4.0
21
// - protoc             (unknown)
22
// source: base/v1/health.proto
23
24
package basev1
25
26
import (
27
	context "context"
28
	grpc "google.golang.org/grpc"
29
	codes "google.golang.org/grpc/codes"
30
	status "google.golang.org/grpc/status"
31
)
32
33
// This is a compile-time assertion to ensure that this generated file
34
// is compatible with the grpc package it is being compiled against.
35
// Requires gRPC-Go v1.62.0 or later.
36
const _ = grpc.SupportPackageIsVersion8
37
38
const (
39
	Health_Check_FullMethodName = "/base.v1.Health/Check"
40
	Health_Watch_FullMethodName = "/base.v1.Health/Watch"
41
)
42
43
// HealthClient is the client API for Health service.
44
//
45
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
46
type HealthClient interface {
47
	// If the requested service is unknown, the call will fail with status
48
	// NOT_FOUND.
49
	Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error)
50
	// Performs a watch for the serving status of the requested service.
51
	// The server will immediately send back a message indicating the current
52
	// serving status.  It will then subsequently send a new message whenever
53
	// the service's serving status changes.
54
	//
55
	// If the requested service is unknown when the call is received, the
56
	// server will send a message setting the serving status to
57
	// SERVICE_UNKNOWN but will *not* terminate the call.  If at some
58
	// future point, the serving status of the service becomes known, the
59
	// server will send a new message with the service's serving status.
60
	//
61
	// If the call terminates with status UNIMPLEMENTED, then clients
62
	// should assume this method is not supported and should not retry the
63
	// call.  If the call terminates with any other status (including OK),
64
	// clients should retry the call with appropriate exponential backoff.
65
	Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (Health_WatchClient, error)
66
}
67
68
type healthClient struct {
69
	cc grpc.ClientConnInterface
70
}
71
72
func NewHealthClient(cc grpc.ClientConnInterface) HealthClient {
73
	return &healthClient{cc}
74
}
75
76
func (c *healthClient) Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) {
77
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
78
	out := new(HealthCheckResponse)
79
	err := c.cc.Invoke(ctx, Health_Check_FullMethodName, in, out, cOpts...)
80
	if err != nil {
81
		return nil, err
82
	}
83
	return out, nil
84
}
85
86
func (c *healthClient) Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (Health_WatchClient, error) {
87
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
88
	stream, err := c.cc.NewStream(ctx, &Health_ServiceDesc.Streams[0], Health_Watch_FullMethodName, cOpts...)
89
	if err != nil {
90
		return nil, err
91
	}
92
	x := &healthWatchClient{ClientStream: stream}
93
	if err := x.ClientStream.SendMsg(in); err != nil {
94
		return nil, err
95
	}
96
	if err := x.ClientStream.CloseSend(); err != nil {
97
		return nil, err
98
	}
99
	return x, nil
100
}
101
102
type Health_WatchClient interface {
103
	Recv() (*HealthCheckResponse, error)
104
	grpc.ClientStream
105
}
106
107
type healthWatchClient struct {
108
	grpc.ClientStream
109
}
110
111
func (x *healthWatchClient) Recv() (*HealthCheckResponse, error) {
112
	m := new(HealthCheckResponse)
113
	if err := x.ClientStream.RecvMsg(m); err != nil {
114
		return nil, err
115
	}
116
	return m, nil
117
}
118
119
// HealthServer is the server API for Health service.
120
// All implementations must embed UnimplementedHealthServer
121
// for forward compatibility
122
type HealthServer interface {
123
	// If the requested service is unknown, the call will fail with status
124
	// NOT_FOUND.
125
	Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error)
126
	// Performs a watch for the serving status of the requested service.
127
	// The server will immediately send back a message indicating the current
128
	// serving status.  It will then subsequently send a new message whenever
129
	// the service's serving status changes.
130
	//
131
	// If the requested service is unknown when the call is received, the
132
	// server will send a message setting the serving status to
133
	// SERVICE_UNKNOWN but will *not* terminate the call.  If at some
134
	// future point, the serving status of the service becomes known, the
135
	// server will send a new message with the service's serving status.
136
	//
137
	// If the call terminates with status UNIMPLEMENTED, then clients
138
	// should assume this method is not supported and should not retry the
139
	// call.  If the call terminates with any other status (including OK),
140
	// clients should retry the call with appropriate exponential backoff.
141
	Watch(*HealthCheckRequest, Health_WatchServer) error
142
	mustEmbedUnimplementedHealthServer()
143
}
144
145
// UnimplementedHealthServer must be embedded to have forward compatible implementations.
146
type UnimplementedHealthServer struct {
147
}
148
149
func (UnimplementedHealthServer) Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) {
150
	return nil, status.Errorf(codes.Unimplemented, "method Check not implemented")
151
}
152
func (UnimplementedHealthServer) Watch(*HealthCheckRequest, Health_WatchServer) error {
153
	return status.Errorf(codes.Unimplemented, "method Watch not implemented")
154
}
155
func (UnimplementedHealthServer) mustEmbedUnimplementedHealthServer() {}
156
157
// UnsafeHealthServer may be embedded to opt out of forward compatibility for this service.
158
// Use of this interface is not recommended, as added methods to HealthServer will
159
// result in compilation errors.
160
type UnsafeHealthServer interface {
161
	mustEmbedUnimplementedHealthServer()
162
}
163
164
func RegisterHealthServer(s grpc.ServiceRegistrar, srv HealthServer) {
165
	s.RegisterService(&Health_ServiceDesc, srv)
166
}
167
168
func _Health_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
169
	in := new(HealthCheckRequest)
170
	if err := dec(in); err != nil {
171
		return nil, err
172
	}
173
	if interceptor == nil {
174
		return srv.(HealthServer).Check(ctx, in)
175
	}
176
	info := &grpc.UnaryServerInfo{
177
		Server:     srv,
178
		FullMethod: Health_Check_FullMethodName,
179
	}
180
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
181
		return srv.(HealthServer).Check(ctx, req.(*HealthCheckRequest))
182
	}
183
	return interceptor(ctx, in, info, handler)
184
}
185
186
func _Health_Watch_Handler(srv interface{}, stream grpc.ServerStream) error {
187
	m := new(HealthCheckRequest)
188
	if err := stream.RecvMsg(m); err != nil {
189
		return err
190
	}
191
	return srv.(HealthServer).Watch(m, &healthWatchServer{ServerStream: stream})
192
}
193
194
type Health_WatchServer interface {
195
	Send(*HealthCheckResponse) error
196
	grpc.ServerStream
197
}
198
199
type healthWatchServer struct {
200
	grpc.ServerStream
201
}
202
203
func (x *healthWatchServer) Send(m *HealthCheckResponse) error {
204
	return x.ServerStream.SendMsg(m)
205
}
206
207
// Health_ServiceDesc is the grpc.ServiceDesc for Health service.
208
// It's only intended for direct use with grpc.RegisterService,
209
// and not to be introspected or modified (even as a copy)
210
var Health_ServiceDesc = grpc.ServiceDesc{
211
	ServiceName: "base.v1.Health",
212
	HandlerType: (*HealthServer)(nil),
213
	Methods: []grpc.MethodDesc{
214
		{
215
			MethodName: "Check",
216
			Handler:    _Health_Check_Handler,
217
		},
218
	},
219
	Streams: []grpc.StreamDesc{
220
		{
221
			StreamName:    "Watch",
222
			Handler:       _Health_Watch_Handler,
223
			ServerStreams: true,
224
		},
225
	},
226
	Metadata: "base/v1/health.proto",
227
}
228