v3election.pb.gw.go 11 KB

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