khenaidoo | d948f77 | 2021-08-11 17:49:24 -0400 | [diff] [blame^] | 1 | // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. |
| 2 | // source: etcdserver/api/v3election/v3electionpb/v3election.proto |
| 3 | |
| 4 | /* |
| 5 | Package v3electionpb is a reverse proxy. |
| 6 | |
| 7 | It translates gRPC into RESTful JSON APIs. |
| 8 | */ |
| 9 | package gw |
| 10 | |
| 11 | import ( |
| 12 | "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb" |
| 13 | "io" |
| 14 | "net/http" |
| 15 | |
| 16 | "github.com/golang/protobuf/proto" |
| 17 | "github.com/grpc-ecosystem/grpc-gateway/runtime" |
| 18 | "github.com/grpc-ecosystem/grpc-gateway/utilities" |
| 19 | "golang.org/x/net/context" |
| 20 | "google.golang.org/grpc" |
| 21 | "google.golang.org/grpc/codes" |
| 22 | "google.golang.org/grpc/grpclog" |
| 23 | "google.golang.org/grpc/status" |
| 24 | ) |
| 25 | |
| 26 | var _ codes.Code |
| 27 | var _ io.Reader |
| 28 | var _ status.Status |
| 29 | var _ = runtime.String |
| 30 | var _ = utilities.NewDoubleArray |
| 31 | |
| 32 | func request_Election_Campaign_0(ctx context.Context, marshaler runtime.Marshaler, client v3electionpb.ElectionClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { |
| 33 | var protoReq v3electionpb.CampaignRequest |
| 34 | var metadata runtime.ServerMetadata |
| 35 | |
| 36 | if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil { |
| 37 | return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) |
| 38 | } |
| 39 | |
| 40 | msg, err := client.Campaign(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) |
| 41 | return msg, metadata, err |
| 42 | |
| 43 | } |
| 44 | |
| 45 | func request_Election_Proclaim_0(ctx context.Context, marshaler runtime.Marshaler, client v3electionpb.ElectionClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { |
| 46 | var protoReq v3electionpb.ProclaimRequest |
| 47 | var metadata runtime.ServerMetadata |
| 48 | |
| 49 | if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil { |
| 50 | return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) |
| 51 | } |
| 52 | |
| 53 | msg, err := client.Proclaim(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) |
| 54 | return msg, metadata, err |
| 55 | |
| 56 | } |
| 57 | |
| 58 | func request_Election_Leader_0(ctx context.Context, marshaler runtime.Marshaler, client v3electionpb.ElectionClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { |
| 59 | var protoReq v3electionpb.LeaderRequest |
| 60 | var metadata runtime.ServerMetadata |
| 61 | |
| 62 | if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil { |
| 63 | return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) |
| 64 | } |
| 65 | |
| 66 | msg, err := client.Leader(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) |
| 67 | return msg, metadata, err |
| 68 | |
| 69 | } |
| 70 | |
| 71 | func request_Election_Observe_0(ctx context.Context, marshaler runtime.Marshaler, client v3electionpb.ElectionClient, req *http.Request, pathParams map[string]string) (v3electionpb.Election_ObserveClient, runtime.ServerMetadata, error) { |
| 72 | var protoReq v3electionpb.LeaderRequest |
| 73 | var metadata runtime.ServerMetadata |
| 74 | |
| 75 | if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil { |
| 76 | return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) |
| 77 | } |
| 78 | |
| 79 | stream, err := client.Observe(ctx, &protoReq) |
| 80 | if err != nil { |
| 81 | return nil, metadata, err |
| 82 | } |
| 83 | header, err := stream.Header() |
| 84 | if err != nil { |
| 85 | return nil, metadata, err |
| 86 | } |
| 87 | metadata.HeaderMD = header |
| 88 | return stream, metadata, nil |
| 89 | |
| 90 | } |
| 91 | |
| 92 | func request_Election_Resign_0(ctx context.Context, marshaler runtime.Marshaler, client v3electionpb.ElectionClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { |
| 93 | var protoReq v3electionpb.ResignRequest |
| 94 | var metadata runtime.ServerMetadata |
| 95 | |
| 96 | if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil { |
| 97 | return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) |
| 98 | } |
| 99 | |
| 100 | msg, err := client.Resign(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) |
| 101 | return msg, metadata, err |
| 102 | |
| 103 | } |
| 104 | |
| 105 | // RegisterElectionHandlerFromEndpoint is same as RegisterElectionHandler but |
| 106 | // automatically dials to "endpoint" and closes the connection when "ctx" gets done. |
| 107 | func RegisterElectionHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { |
| 108 | conn, err := grpc.Dial(endpoint, opts...) |
| 109 | if err != nil { |
| 110 | return err |
| 111 | } |
| 112 | defer func() { |
| 113 | if err != nil { |
| 114 | if cerr := conn.Close(); cerr != nil { |
| 115 | grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr) |
| 116 | } |
| 117 | return |
| 118 | } |
| 119 | go func() { |
| 120 | <-ctx.Done() |
| 121 | if cerr := conn.Close(); cerr != nil { |
| 122 | grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr) |
| 123 | } |
| 124 | }() |
| 125 | }() |
| 126 | |
| 127 | return RegisterElectionHandler(ctx, mux, conn) |
| 128 | } |
| 129 | |
| 130 | // RegisterElectionHandler registers the http handlers for service Election to "mux". |
| 131 | // The handlers forward requests to the grpc endpoint over "conn". |
| 132 | func RegisterElectionHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { |
| 133 | return RegisterElectionHandlerClient(ctx, mux, v3electionpb.NewElectionClient(conn)) |
| 134 | } |
| 135 | |
| 136 | // RegisterElectionHandler registers the http handlers for service Election to "mux". |
| 137 | // The handlers forward requests to the grpc endpoint over the given implementation of "ElectionClient". |
| 138 | // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ElectionClient" |
| 139 | // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in |
| 140 | // "ElectionClient" to call the correct interceptors. |
| 141 | func RegisterElectionHandlerClient(ctx context.Context, mux *runtime.ServeMux, client v3electionpb.ElectionClient) error { |
| 142 | |
| 143 | mux.Handle("POST", pattern_Election_Campaign_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { |
| 144 | ctx, cancel := context.WithCancel(req.Context()) |
| 145 | defer cancel() |
| 146 | if cn, ok := w.(http.CloseNotifier); ok { |
| 147 | go func(done <-chan struct{}, closed <-chan bool) { |
| 148 | select { |
| 149 | case <-done: |
| 150 | case <-closed: |
| 151 | cancel() |
| 152 | } |
| 153 | }(ctx.Done(), cn.CloseNotify()) |
| 154 | } |
| 155 | inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) |
| 156 | rctx, err := runtime.AnnotateContext(ctx, mux, req) |
| 157 | if err != nil { |
| 158 | runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) |
| 159 | return |
| 160 | } |
| 161 | resp, md, err := request_Election_Campaign_0(rctx, inboundMarshaler, client, req, pathParams) |
| 162 | ctx = runtime.NewServerMetadataContext(ctx, md) |
| 163 | if err != nil { |
| 164 | runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) |
| 165 | return |
| 166 | } |
| 167 | |
| 168 | forward_Election_Campaign_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) |
| 169 | |
| 170 | }) |
| 171 | |
| 172 | mux.Handle("POST", pattern_Election_Proclaim_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { |
| 173 | ctx, cancel := context.WithCancel(req.Context()) |
| 174 | defer cancel() |
| 175 | if cn, ok := w.(http.CloseNotifier); ok { |
| 176 | go func(done <-chan struct{}, closed <-chan bool) { |
| 177 | select { |
| 178 | case <-done: |
| 179 | case <-closed: |
| 180 | cancel() |
| 181 | } |
| 182 | }(ctx.Done(), cn.CloseNotify()) |
| 183 | } |
| 184 | inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) |
| 185 | rctx, err := runtime.AnnotateContext(ctx, mux, req) |
| 186 | if err != nil { |
| 187 | runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) |
| 188 | return |
| 189 | } |
| 190 | resp, md, err := request_Election_Proclaim_0(rctx, inboundMarshaler, client, req, pathParams) |
| 191 | ctx = runtime.NewServerMetadataContext(ctx, md) |
| 192 | if err != nil { |
| 193 | runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) |
| 194 | return |
| 195 | } |
| 196 | |
| 197 | forward_Election_Proclaim_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) |
| 198 | |
| 199 | }) |
| 200 | |
| 201 | mux.Handle("POST", pattern_Election_Leader_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { |
| 202 | ctx, cancel := context.WithCancel(req.Context()) |
| 203 | defer cancel() |
| 204 | if cn, ok := w.(http.CloseNotifier); ok { |
| 205 | go func(done <-chan struct{}, closed <-chan bool) { |
| 206 | select { |
| 207 | case <-done: |
| 208 | case <-closed: |
| 209 | cancel() |
| 210 | } |
| 211 | }(ctx.Done(), cn.CloseNotify()) |
| 212 | } |
| 213 | inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) |
| 214 | rctx, err := runtime.AnnotateContext(ctx, mux, req) |
| 215 | if err != nil { |
| 216 | runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) |
| 217 | return |
| 218 | } |
| 219 | resp, md, err := request_Election_Leader_0(rctx, inboundMarshaler, client, req, pathParams) |
| 220 | ctx = runtime.NewServerMetadataContext(ctx, md) |
| 221 | if err != nil { |
| 222 | runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) |
| 223 | return |
| 224 | } |
| 225 | |
| 226 | forward_Election_Leader_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) |
| 227 | |
| 228 | }) |
| 229 | |
| 230 | mux.Handle("POST", pattern_Election_Observe_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { |
| 231 | ctx, cancel := context.WithCancel(req.Context()) |
| 232 | defer cancel() |
| 233 | if cn, ok := w.(http.CloseNotifier); ok { |
| 234 | go func(done <-chan struct{}, closed <-chan bool) { |
| 235 | select { |
| 236 | case <-done: |
| 237 | case <-closed: |
| 238 | cancel() |
| 239 | } |
| 240 | }(ctx.Done(), cn.CloseNotify()) |
| 241 | } |
| 242 | inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) |
| 243 | rctx, err := runtime.AnnotateContext(ctx, mux, req) |
| 244 | if err != nil { |
| 245 | runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) |
| 246 | return |
| 247 | } |
| 248 | resp, md, err := request_Election_Observe_0(rctx, inboundMarshaler, client, req, pathParams) |
| 249 | ctx = runtime.NewServerMetadataContext(ctx, md) |
| 250 | if err != nil { |
| 251 | runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) |
| 252 | return |
| 253 | } |
| 254 | |
| 255 | forward_Election_Observe_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) |
| 256 | |
| 257 | }) |
| 258 | |
| 259 | mux.Handle("POST", pattern_Election_Resign_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { |
| 260 | ctx, cancel := context.WithCancel(req.Context()) |
| 261 | defer cancel() |
| 262 | if cn, ok := w.(http.CloseNotifier); ok { |
| 263 | go func(done <-chan struct{}, closed <-chan bool) { |
| 264 | select { |
| 265 | case <-done: |
| 266 | case <-closed: |
| 267 | cancel() |
| 268 | } |
| 269 | }(ctx.Done(), cn.CloseNotify()) |
| 270 | } |
| 271 | inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) |
| 272 | rctx, err := runtime.AnnotateContext(ctx, mux, req) |
| 273 | if err != nil { |
| 274 | runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) |
| 275 | return |
| 276 | } |
| 277 | resp, md, err := request_Election_Resign_0(rctx, inboundMarshaler, client, req, pathParams) |
| 278 | ctx = runtime.NewServerMetadataContext(ctx, md) |
| 279 | if err != nil { |
| 280 | runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) |
| 281 | return |
| 282 | } |
| 283 | |
| 284 | forward_Election_Resign_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) |
| 285 | |
| 286 | }) |
| 287 | |
| 288 | return nil |
| 289 | } |
| 290 | |
| 291 | var ( |
| 292 | pattern_Election_Campaign_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3beta", "election", "campaign"}, "")) |
| 293 | |
| 294 | pattern_Election_Proclaim_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3beta", "election", "proclaim"}, "")) |
| 295 | |
| 296 | pattern_Election_Leader_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3beta", "election", "leader"}, "")) |
| 297 | |
| 298 | pattern_Election_Observe_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3beta", "election", "observe"}, "")) |
| 299 | |
| 300 | pattern_Election_Resign_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3beta", "election", "resign"}, "")) |
| 301 | ) |
| 302 | |
| 303 | var ( |
| 304 | forward_Election_Campaign_0 = runtime.ForwardResponseMessage |
| 305 | |
| 306 | forward_Election_Proclaim_0 = runtime.ForwardResponseMessage |
| 307 | |
| 308 | forward_Election_Leader_0 = runtime.ForwardResponseMessage |
| 309 | |
| 310 | forward_Election_Observe_0 = runtime.ForwardResponseStream |
| 311 | |
| 312 | forward_Election_Resign_0 = runtime.ForwardResponseMessage |
| 313 | ) |