aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/google.golang.org/grpc/health
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/google.golang.org/grpc/health')
-rw-r--r--vendor/google.golang.org/grpc/health/grpc_health_v1/health.pb.go176
-rw-r--r--vendor/google.golang.org/grpc/health/grpc_health_v1/health.proto34
-rw-r--r--vendor/google.golang.org/grpc/health/health.go70
3 files changed, 280 insertions, 0 deletions
diff --git a/vendor/google.golang.org/grpc/health/grpc_health_v1/health.pb.go b/vendor/google.golang.org/grpc/health/grpc_health_v1/health.pb.go
new file mode 100644
index 0000000..89c4d45
--- /dev/null
+++ b/vendor/google.golang.org/grpc/health/grpc_health_v1/health.pb.go
@@ -0,0 +1,176 @@
1// Code generated by protoc-gen-go.
2// source: health.proto
3// DO NOT EDIT!
4
5/*
6Package grpc_health_v1 is a generated protocol buffer package.
7
8It is generated from these files:
9 health.proto
10
11It has these top-level messages:
12 HealthCheckRequest
13 HealthCheckResponse
14*/
15package grpc_health_v1
16
17import proto "github.com/golang/protobuf/proto"
18import fmt "fmt"
19import math "math"
20
21import (
22 context "golang.org/x/net/context"
23 grpc "google.golang.org/grpc"
24)
25
26// Reference imports to suppress errors if they are not otherwise used.
27var _ = proto.Marshal
28var _ = fmt.Errorf
29var _ = math.Inf
30
31// This is a compile-time assertion to ensure that this generated file
32// is compatible with the proto package it is being compiled against.
33// A compilation error at this line likely means your copy of the
34// proto package needs to be updated.
35const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
36
37type HealthCheckResponse_ServingStatus int32
38
39const (
40 HealthCheckResponse_UNKNOWN HealthCheckResponse_ServingStatus = 0
41 HealthCheckResponse_SERVING HealthCheckResponse_ServingStatus = 1
42 HealthCheckResponse_NOT_SERVING HealthCheckResponse_ServingStatus = 2
43)
44
45var HealthCheckResponse_ServingStatus_name = map[int32]string{
46 0: "UNKNOWN",
47 1: "SERVING",
48 2: "NOT_SERVING",
49}
50var HealthCheckResponse_ServingStatus_value = map[string]int32{
51 "UNKNOWN": 0,
52 "SERVING": 1,
53 "NOT_SERVING": 2,
54}
55
56func (x HealthCheckResponse_ServingStatus) String() string {
57 return proto.EnumName(HealthCheckResponse_ServingStatus_name, int32(x))
58}
59func (HealthCheckResponse_ServingStatus) EnumDescriptor() ([]byte, []int) {
60 return fileDescriptor0, []int{1, 0}
61}
62
63type HealthCheckRequest struct {
64 Service string `protobuf:"bytes,1,opt,name=service" json:"service,omitempty"`
65}
66
67func (m *HealthCheckRequest) Reset() { *m = HealthCheckRequest{} }
68func (m *HealthCheckRequest) String() string { return proto.CompactTextString(m) }
69func (*HealthCheckRequest) ProtoMessage() {}
70func (*HealthCheckRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
71
72type HealthCheckResponse struct {
73 Status HealthCheckResponse_ServingStatus `protobuf:"varint,1,opt,name=status,enum=grpc.health.v1.HealthCheckResponse_ServingStatus" json:"status,omitempty"`
74}
75
76func (m *HealthCheckResponse) Reset() { *m = HealthCheckResponse{} }
77func (m *HealthCheckResponse) String() string { return proto.CompactTextString(m) }
78func (*HealthCheckResponse) ProtoMessage() {}
79func (*HealthCheckResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
80
81func init() {
82 proto.RegisterType((*HealthCheckRequest)(nil), "grpc.health.v1.HealthCheckRequest")
83 proto.RegisterType((*HealthCheckResponse)(nil), "grpc.health.v1.HealthCheckResponse")
84 proto.RegisterEnum("grpc.health.v1.HealthCheckResponse_ServingStatus", HealthCheckResponse_ServingStatus_name, HealthCheckResponse_ServingStatus_value)
85}
86
87// Reference imports to suppress errors if they are not otherwise used.
88var _ context.Context
89var _ grpc.ClientConn
90
91// This is a compile-time assertion to ensure that this generated file
92// is compatible with the grpc package it is being compiled against.
93const _ = grpc.SupportPackageIsVersion4
94
95// Client API for Health service
96
97type HealthClient interface {
98 Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error)
99}
100
101type healthClient struct {
102 cc *grpc.ClientConn
103}
104
105func NewHealthClient(cc *grpc.ClientConn) HealthClient {
106 return &healthClient{cc}
107}
108
109func (c *healthClient) Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) {
110 out := new(HealthCheckResponse)
111 err := grpc.Invoke(ctx, "/grpc.health.v1.Health/Check", in, out, c.cc, opts...)
112 if err != nil {
113 return nil, err
114 }
115 return out, nil
116}
117
118// Server API for Health service
119
120type HealthServer interface {
121 Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error)
122}
123
124func RegisterHealthServer(s *grpc.Server, srv HealthServer) {
125 s.RegisterService(&_Health_serviceDesc, srv)
126}
127
128func _Health_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
129 in := new(HealthCheckRequest)
130 if err := dec(in); err != nil {
131 return nil, err
132 }
133 if interceptor == nil {
134 return srv.(HealthServer).Check(ctx, in)
135 }
136 info := &grpc.UnaryServerInfo{
137 Server: srv,
138 FullMethod: "/grpc.health.v1.Health/Check",
139 }
140 handler := func(ctx context.Context, req interface{}) (interface{}, error) {
141 return srv.(HealthServer).Check(ctx, req.(*HealthCheckRequest))
142 }
143 return interceptor(ctx, in, info, handler)
144}
145
146var _Health_serviceDesc = grpc.ServiceDesc{
147 ServiceName: "grpc.health.v1.Health",
148 HandlerType: (*HealthServer)(nil),
149 Methods: []grpc.MethodDesc{
150 {
151 MethodName: "Check",
152 Handler: _Health_Check_Handler,
153 },
154 },
155 Streams: []grpc.StreamDesc{},
156 Metadata: "health.proto",
157}
158
159func init() { proto.RegisterFile("health.proto", fileDescriptor0) }
160
161var fileDescriptor0 = []byte{
162 // 204 bytes of a gzipped FileDescriptorProto
163 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0xc9, 0x48, 0x4d, 0xcc,
164 0x29, 0xc9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4b, 0x2f, 0x2a, 0x48, 0xd6, 0x83,
165 0x0a, 0x95, 0x19, 0x2a, 0xe9, 0x71, 0x09, 0x79, 0x80, 0x39, 0xce, 0x19, 0xa9, 0xc9, 0xd9, 0x41,
166 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x42, 0x12, 0x5c, 0xec, 0xc5, 0xa9, 0x45, 0x65, 0x99, 0xc9,
167 0xa9, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x30, 0xae, 0xd2, 0x1c, 0x46, 0x2e, 0x61, 0x14,
168 0x0d, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x42, 0x9e, 0x5c, 0x6c, 0xc5, 0x25, 0x89, 0x25, 0xa5,
169 0xc5, 0x60, 0x0d, 0x7c, 0x46, 0x86, 0x7a, 0xa8, 0x16, 0xe9, 0x61, 0xd1, 0xa4, 0x17, 0x0c, 0x32,
170 0x34, 0x2f, 0x3d, 0x18, 0xac, 0x31, 0x08, 0x6a, 0x80, 0x92, 0x15, 0x17, 0x2f, 0x8a, 0x84, 0x10,
171 0x37, 0x17, 0x7b, 0xa8, 0x9f, 0xb7, 0x9f, 0x7f, 0xb8, 0x9f, 0x00, 0x03, 0x88, 0x13, 0xec, 0x1a,
172 0x14, 0xe6, 0xe9, 0xe7, 0x2e, 0xc0, 0x28, 0xc4, 0xcf, 0xc5, 0xed, 0xe7, 0x1f, 0x12, 0x0f, 0x13,
173 0x60, 0x32, 0x8a, 0xe2, 0x62, 0x83, 0x58, 0x24, 0x14, 0xc0, 0xc5, 0x0a, 0xb6, 0x4c, 0x48, 0x09,
174 0xaf, 0x4b, 0xc0, 0xfe, 0x95, 0x52, 0x26, 0xc2, 0xb5, 0x49, 0x6c, 0xe0, 0x10, 0x34, 0x06, 0x04,
175 0x00, 0x00, 0xff, 0xff, 0xac, 0x56, 0x2a, 0xcb, 0x51, 0x01, 0x00, 0x00,
176}
diff --git a/vendor/google.golang.org/grpc/health/grpc_health_v1/health.proto b/vendor/google.golang.org/grpc/health/grpc_health_v1/health.proto
new file mode 100644
index 0000000..6072fdc
--- /dev/null
+++ b/vendor/google.golang.org/grpc/health/grpc_health_v1/health.proto
@@ -0,0 +1,34 @@
1// Copyright 2017 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
15syntax = "proto3";
16
17package grpc.health.v1;
18
19message HealthCheckRequest {
20 string service = 1;
21}
22
23message HealthCheckResponse {
24 enum ServingStatus {
25 UNKNOWN = 0;
26 SERVING = 1;
27 NOT_SERVING = 2;
28 }
29 ServingStatus status = 1;
30}
31
32service Health{
33 rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
34}
diff --git a/vendor/google.golang.org/grpc/health/health.go b/vendor/google.golang.org/grpc/health/health.go
new file mode 100644
index 0000000..4dccbc7
--- /dev/null
+++ b/vendor/google.golang.org/grpc/health/health.go
@@ -0,0 +1,70 @@
1/*
2 *
3 * Copyright 2017 gRPC authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19// Package health provides some utility functions to health-check a server. The implementation
20// is based on protobuf. Users need to write their own implementations if other IDLs are used.
21package health
22
23import (
24 "sync"
25
26 "golang.org/x/net/context"
27 "google.golang.org/grpc"
28 "google.golang.org/grpc/codes"
29 healthpb "google.golang.org/grpc/health/grpc_health_v1"
30)
31
32// Server implements `service Health`.
33type Server struct {
34 mu sync.Mutex
35 // statusMap stores the serving status of the services this Server monitors.
36 statusMap map[string]healthpb.HealthCheckResponse_ServingStatus
37}
38
39// NewServer returns a new Server.
40func NewServer() *Server {
41 return &Server{
42 statusMap: make(map[string]healthpb.HealthCheckResponse_ServingStatus),
43 }
44}
45
46// Check implements `service Health`.
47func (s *Server) Check(ctx context.Context, in *healthpb.HealthCheckRequest) (*healthpb.HealthCheckResponse, error) {
48 s.mu.Lock()
49 defer s.mu.Unlock()
50 if in.Service == "" {
51 // check the server overall health status.
52 return &healthpb.HealthCheckResponse{
53 Status: healthpb.HealthCheckResponse_SERVING,
54 }, nil
55 }
56 if status, ok := s.statusMap[in.Service]; ok {
57 return &healthpb.HealthCheckResponse{
58 Status: status,
59 }, nil
60 }
61 return nil, grpc.Errorf(codes.NotFound, "unknown service")
62}
63
64// SetServingStatus is called when need to reset the serving status of a service
65// or insert a new service entry into the statusMap.
66func (s *Server) SetServingStatus(service string, status healthpb.HealthCheckResponse_ServingStatus) {
67 s.mu.Lock()
68 s.statusMap[service] = status
69 s.mu.Unlock()
70}