阶段性提交

This commit is contained in:
GoEdgeLab
2020-09-15 14:44:52 +08:00
parent e3501a5a68
commit 4807a6672f
27 changed files with 1354 additions and 115 deletions

View File

@@ -26,6 +26,8 @@ type RPCClient struct {
serverClients []pb.ServerServiceClient
apiNodeClients []pb.APINodeServiceClient
originNodeClients []pb.OriginServerServiceClient
httpWebClients []pb.HTTPWebServiceClient
reverseProxyClients []pb.ReverseProxyServiceClient
}
func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
@@ -41,6 +43,8 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
serverClients := []pb.ServerServiceClient{}
apiNodeClients := []pb.APINodeServiceClient{}
originNodeClients := []pb.OriginServerServiceClient{}
httpWebClients := []pb.HTTPWebServiceClient{}
reverseProxyClients := []pb.ReverseProxyServiceClient{}
conns := []*grpc.ClientConn{}
for _, endpoint := range apiConfig.RPC.Endpoints {
@@ -64,6 +68,8 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
serverClients = append(serverClients, pb.NewServerServiceClient(conn))
apiNodeClients = append(apiNodeClients, pb.NewAPINodeServiceClient(conn))
originNodeClients = append(originNodeClients, pb.NewOriginServerServiceClient(conn))
httpWebClients = append(httpWebClients, pb.NewHTTPWebServiceClient(conn))
reverseProxyClients = append(reverseProxyClients, pb.NewReverseProxyServiceClient(conn))
}
return &RPCClient{
@@ -76,6 +82,8 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
serverClients: serverClients,
apiNodeClients: apiNodeClients,
originNodeClients: originNodeClients,
httpWebClients: httpWebClients,
reverseProxyClients: reverseProxyClients,
}, nil
}
@@ -135,6 +143,20 @@ func (this *RPCClient) OriginServerRPC() pb.OriginServerServiceClient {
return nil
}
func (this *RPCClient) HTTPWebRPC() pb.HTTPWebServiceClient {
if len(this.httpWebClients) > 0 {
return this.httpWebClients[rands.Int(0, len(this.httpWebClients)-1)]
}
return nil
}
func (this *RPCClient) ReverseProxyRPC() pb.ReverseProxyServiceClient {
if len(this.reverseProxyClients) > 0 {
return this.reverseProxyClients[rands.Int(0, len(this.reverseProxyClients)-1)]
}
return nil
}
func (this *RPCClient) Context(adminId int64) context.Context {
ctx := context.Background()
m := maps.Map{