1
|
|
|
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. |
2
|
|
|
// source: base/v1/health.proto |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
Package basev1 is a reverse proxy. |
6
|
|
|
|
7
|
|
|
It translates gRPC into RESTful JSON APIs. |
8
|
|
|
*/ |
9
|
|
|
package basev1 |
10
|
|
|
|
11
|
|
|
import ( |
12
|
|
|
"context" |
13
|
|
|
"io" |
14
|
|
|
"net/http" |
15
|
|
|
|
16
|
|
|
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime" |
17
|
|
|
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities" |
18
|
|
|
"google.golang.org/grpc" |
19
|
|
|
"google.golang.org/grpc/codes" |
20
|
|
|
"google.golang.org/grpc/grpclog" |
21
|
|
|
"google.golang.org/grpc/metadata" |
22
|
|
|
"google.golang.org/grpc/status" |
23
|
|
|
"google.golang.org/protobuf/proto" |
24
|
|
|
) |
25
|
|
|
|
26
|
|
|
// Suppress "imported and not used" errors |
27
|
|
|
var _ codes.Code |
28
|
|
|
var _ io.Reader |
29
|
|
|
var _ status.Status |
30
|
|
|
var _ = runtime.String |
31
|
|
|
var _ = utilities.NewDoubleArray |
32
|
|
|
var _ = metadata.Join |
33
|
|
|
|
34
|
|
|
var ( |
35
|
|
|
filter_Health_Check_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} |
36
|
|
|
) |
37
|
|
|
|
38
|
|
|
func request_Health_Check_0(ctx context.Context, marshaler runtime.Marshaler, client HealthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { |
39
|
|
|
var protoReq HealthCheckRequest |
40
|
|
|
var metadata runtime.ServerMetadata |
41
|
|
|
|
42
|
|
|
if err := req.ParseForm(); err != nil { |
43
|
|
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) |
44
|
|
|
} |
45
|
|
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Health_Check_0); err != nil { |
46
|
|
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
msg, err := client.Check(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) |
50
|
|
|
return msg, metadata, err |
51
|
|
|
|
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
func local_request_Health_Check_0(ctx context.Context, marshaler runtime.Marshaler, server HealthServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { |
55
|
|
|
var protoReq HealthCheckRequest |
56
|
|
|
var metadata runtime.ServerMetadata |
57
|
|
|
|
58
|
|
|
if err := req.ParseForm(); err != nil { |
59
|
|
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) |
60
|
|
|
} |
61
|
|
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Health_Check_0); err != nil { |
62
|
|
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
msg, err := server.Check(ctx, &protoReq) |
66
|
|
|
return msg, metadata, err |
67
|
|
|
|
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
// RegisterHealthHandlerServer registers the http handlers for service Health to "mux". |
71
|
|
|
// UnaryRPC :call HealthServer directly. |
72
|
|
|
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. |
73
|
|
|
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterHealthHandlerFromEndpoint instead. |
74
|
|
|
func RegisterHealthHandlerServer(ctx context.Context, mux *runtime.ServeMux, server HealthServer) error { |
75
|
|
|
|
76
|
|
|
mux.Handle("GET", pattern_Health_Check_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { |
77
|
|
|
ctx, cancel := context.WithCancel(req.Context()) |
78
|
|
|
defer cancel() |
79
|
|
|
var stream runtime.ServerTransportStream |
80
|
|
|
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) |
81
|
|
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) |
82
|
|
|
var err error |
83
|
|
|
var annotatedContext context.Context |
84
|
|
|
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/base.v1.Health/Check", runtime.WithHTTPPathPattern("/healthz")) |
85
|
|
|
if err != nil { |
86
|
|
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) |
87
|
|
|
return |
88
|
|
|
} |
89
|
|
|
resp, md, err := local_request_Health_Check_0(annotatedContext, inboundMarshaler, server, req, pathParams) |
90
|
|
|
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) |
91
|
|
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) |
92
|
|
|
if err != nil { |
93
|
|
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) |
94
|
|
|
return |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
forward_Health_Check_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) |
98
|
|
|
|
99
|
|
|
}) |
100
|
|
|
|
101
|
|
|
return nil |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
// RegisterHealthHandlerFromEndpoint is same as RegisterHealthHandler but |
105
|
|
|
// automatically dials to "endpoint" and closes the connection when "ctx" gets done. |
106
|
|
|
func RegisterHealthHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { |
107
|
|
|
conn, err := grpc.NewClient(endpoint, opts...) |
108
|
|
|
if err != nil { |
109
|
|
|
return err |
110
|
|
|
} |
111
|
|
|
defer func() { |
112
|
|
|
if err != nil { |
113
|
|
|
if cerr := conn.Close(); cerr != nil { |
114
|
|
|
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) |
115
|
|
|
} |
116
|
|
|
return |
117
|
|
|
} |
118
|
|
|
go func() { |
119
|
|
|
<-ctx.Done() |
120
|
|
|
if cerr := conn.Close(); cerr != nil { |
121
|
|
|
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) |
122
|
|
|
} |
123
|
|
|
}() |
124
|
|
|
}() |
125
|
|
|
|
126
|
|
|
return RegisterHealthHandler(ctx, mux, conn) |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
// RegisterHealthHandler registers the http handlers for service Health to "mux". |
130
|
|
|
// The handlers forward requests to the grpc endpoint over "conn". |
131
|
|
|
func RegisterHealthHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { |
132
|
|
|
return RegisterHealthHandlerClient(ctx, mux, NewHealthClient(conn)) |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
// RegisterHealthHandlerClient registers the http handlers for service Health |
136
|
|
|
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "HealthClient". |
137
|
|
|
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "HealthClient" |
138
|
|
|
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in |
139
|
|
|
// "HealthClient" to call the correct interceptors. |
140
|
|
|
func RegisterHealthHandlerClient(ctx context.Context, mux *runtime.ServeMux, client HealthClient) error { |
141
|
|
|
|
142
|
|
|
mux.Handle("GET", pattern_Health_Check_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { |
143
|
|
|
ctx, cancel := context.WithCancel(req.Context()) |
144
|
|
|
defer cancel() |
145
|
|
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) |
146
|
|
|
var err error |
147
|
|
|
var annotatedContext context.Context |
148
|
|
|
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/base.v1.Health/Check", runtime.WithHTTPPathPattern("/healthz")) |
149
|
|
|
if err != nil { |
150
|
|
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) |
151
|
|
|
return |
152
|
|
|
} |
153
|
|
|
resp, md, err := request_Health_Check_0(annotatedContext, inboundMarshaler, client, req, pathParams) |
154
|
|
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) |
155
|
|
|
if err != nil { |
156
|
|
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) |
157
|
|
|
return |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
forward_Health_Check_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) |
161
|
|
|
|
162
|
|
|
}) |
163
|
|
|
|
164
|
|
|
return nil |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
var ( |
168
|
|
|
pattern_Health_Check_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"healthz"}, "")) |
169
|
|
|
) |
170
|
|
|
|
171
|
|
|
var ( |
172
|
|
|
forward_Health_Check_0 = runtime.ForwardResponseMessage |
173
|
|
|
) |
174
|
|
|
|