feat:multi cluster application

This commit is contained in:
pengcong06
2020-05-25 22:38:03 +08:00
parent d4b7d88b4b
commit 59839439d5
73 changed files with 9838 additions and 6278 deletions

View File

@@ -9,24 +9,27 @@ It translates gRPC into RESTful JSON APIs.
package pb
import (
"context"
"io"
"net/http"
"github.com/golang/protobuf/descriptor"
"github.com/golang/protobuf/proto"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/utilities"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/status"
)
// Suppress "imported and not used" errors
var _ codes.Code
var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
var _ = descriptor.ForMessage
var (
filter_JobManager_DescribeJobs_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
@@ -36,7 +39,10 @@ func request_JobManager_DescribeJobs_0(ctx context.Context, marshaler runtime.Ma
var protoReq DescribeJobsRequest
var metadata runtime.ServerMetadata
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_JobManager_DescribeJobs_0); err != nil {
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_JobManager_DescribeJobs_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
@@ -45,6 +51,47 @@ func request_JobManager_DescribeJobs_0(ctx context.Context, marshaler runtime.Ma
}
func local_request_JobManager_DescribeJobs_0(ctx context.Context, marshaler runtime.Marshaler, server JobManagerServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq DescribeJobsRequest
var metadata runtime.ServerMetadata
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_JobManager_DescribeJobs_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.DescribeJobs(ctx, &protoReq)
return msg, metadata, err
}
// RegisterJobManagerHandlerServer registers the http handlers for service JobManager to "mux".
// UnaryRPC :call JobManagerServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
func RegisterJobManagerHandlerServer(ctx context.Context, mux *runtime.ServeMux, server JobManagerServer) error {
mux.Handle("GET", pattern_JobManager_DescribeJobs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_JobManager_DescribeJobs_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_JobManager_DescribeJobs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterJobManagerHandlerFromEndpoint is same as RegisterJobManagerHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterJobManagerHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
@@ -86,15 +133,6 @@ func RegisterJobManagerHandlerClient(ctx context.Context, mux *runtime.ServeMux,
mux.Handle("GET", pattern_JobManager_DescribeJobs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
@@ -116,7 +154,7 @@ func RegisterJobManagerHandlerClient(ctx context.Context, mux *runtime.ServeMux,
}
var (
pattern_JobManager_DescribeJobs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "jobs"}, ""))
pattern_JobManager_DescribeJobs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "jobs"}, "", runtime.AssumeColonVerbOpt(true)))
)
var (