v3lock.pb.gw.go 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
  2. // source: etcdserver/api/v3lock/v3lockpb/v3lock.proto
  3. /*
  4. Package v3lockpb 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/v3lock/v3lockpb"
  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_Lock_Lock_0(ctx context.Context, marshaler runtime.Marshaler, client v3lockpb.LockClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  27. var protoReq v3lockpb.LockRequest
  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.Lock(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
  33. return msg, metadata, err
  34. }
  35. func request_Lock_Unlock_0(ctx context.Context, marshaler runtime.Marshaler, client v3lockpb.LockClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  36. var protoReq v3lockpb.UnlockRequest
  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.Unlock(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
  42. return msg, metadata, err
  43. }
  44. // RegisterLockHandlerFromEndpoint is same as RegisterLockHandler but
  45. // automatically dials to "endpoint" and closes the connection when "ctx" gets done.
  46. func RegisterLockHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
  47. conn, err := grpc.Dial(endpoint, opts...)
  48. if err != nil {
  49. return err
  50. }
  51. defer func() {
  52. if err != nil {
  53. if cerr := conn.Close(); cerr != nil {
  54. grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
  55. }
  56. return
  57. }
  58. go func() {
  59. <-ctx.Done()
  60. if cerr := conn.Close(); cerr != nil {
  61. grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
  62. }
  63. }()
  64. }()
  65. return RegisterLockHandler(ctx, mux, conn)
  66. }
  67. // RegisterLockHandler registers the http handlers for service Lock to "mux".
  68. // The handlers forward requests to the grpc endpoint over "conn".
  69. func RegisterLockHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
  70. return RegisterLockHandlerClient(ctx, mux, v3lockpb.NewLockClient(conn))
  71. }
  72. // RegisterLockHandler registers the http handlers for service Lock to "mux".
  73. // The handlers forward requests to the grpc endpoint over the given implementation of "LockClient".
  74. // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "LockClient"
  75. // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
  76. // "LockClient" to call the correct interceptors.
  77. func RegisterLockHandlerClient(ctx context.Context, mux *runtime.ServeMux, client v3lockpb.LockClient) error {
  78. mux.Handle("POST", pattern_Lock_Lock_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  79. ctx, cancel := context.WithCancel(req.Context())
  80. defer cancel()
  81. if cn, ok := w.(http.CloseNotifier); ok {
  82. go func(done <-chan struct{}, closed <-chan bool) {
  83. select {
  84. case <-done:
  85. case <-closed:
  86. cancel()
  87. }
  88. }(ctx.Done(), cn.CloseNotify())
  89. }
  90. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  91. rctx, err := runtime.AnnotateContext(ctx, mux, req)
  92. if err != nil {
  93. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  94. return
  95. }
  96. resp, md, err := request_Lock_Lock_0(rctx, inboundMarshaler, client, req, pathParams)
  97. ctx = runtime.NewServerMetadataContext(ctx, md)
  98. if err != nil {
  99. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  100. return
  101. }
  102. forward_Lock_Lock_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  103. })
  104. mux.Handle("POST", pattern_Lock_Unlock_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  105. ctx, cancel := context.WithCancel(req.Context())
  106. defer cancel()
  107. if cn, ok := w.(http.CloseNotifier); ok {
  108. go func(done <-chan struct{}, closed <-chan bool) {
  109. select {
  110. case <-done:
  111. case <-closed:
  112. cancel()
  113. }
  114. }(ctx.Done(), cn.CloseNotify())
  115. }
  116. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  117. rctx, err := runtime.AnnotateContext(ctx, mux, req)
  118. if err != nil {
  119. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  120. return
  121. }
  122. resp, md, err := request_Lock_Unlock_0(rctx, inboundMarshaler, client, req, pathParams)
  123. ctx = runtime.NewServerMetadataContext(ctx, md)
  124. if err != nil {
  125. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  126. return
  127. }
  128. forward_Lock_Unlock_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  129. })
  130. return nil
  131. }
  132. var (
  133. pattern_Lock_Lock_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 1}, []string{"v3beta", "lock"}, ""))
  134. pattern_Lock_Unlock_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3beta", "lock", "unlock"}, ""))
  135. )
  136. var (
  137. forward_Lock_Lock_0 = runtime.ForwardResponseMessage
  138. forward_Lock_Unlock_0 = runtime.ForwardResponseMessage
  139. )