阶段性提交

This commit is contained in:
刘祥超
2020-09-16 09:09:10 +08:00
parent eadf69b147
commit 5b35be650b
44 changed files with 959 additions and 279 deletions

View File

@@ -28,6 +28,7 @@ type RPCClient struct {
originNodeClients []pb.OriginServerServiceClient
httpWebClients []pb.HTTPWebServiceClient
reverseProxyClients []pb.ReverseProxyServiceClient
httpGzipClients []pb.HTTPGzipServiceClient
}
func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
@@ -45,6 +46,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
originNodeClients := []pb.OriginServerServiceClient{}
httpWebClients := []pb.HTTPWebServiceClient{}
reverseProxyClients := []pb.ReverseProxyServiceClient{}
httpGzipClients := []pb.HTTPGzipServiceClient{}
conns := []*grpc.ClientConn{}
for _, endpoint := range apiConfig.RPC.Endpoints {
@@ -70,6 +72,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
originNodeClients = append(originNodeClients, pb.NewOriginServerServiceClient(conn))
httpWebClients = append(httpWebClients, pb.NewHTTPWebServiceClient(conn))
reverseProxyClients = append(reverseProxyClients, pb.NewReverseProxyServiceClient(conn))
httpGzipClients = append(httpGzipClients, pb.NewHTTPGzipServiceClient(conn))
}
return &RPCClient{
@@ -84,6 +87,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
originNodeClients: originNodeClients,
httpWebClients: httpWebClients,
reverseProxyClients: reverseProxyClients,
httpGzipClients: httpGzipClients,
}, nil
}
@@ -157,6 +161,13 @@ func (this *RPCClient) ReverseProxyRPC() pb.ReverseProxyServiceClient {
return nil
}
func (this *RPCClient) HTTPGzipRPC() pb.HTTPGzipServiceClient {
if len(this.httpGzipClients) > 0 {
return this.httpGzipClients[rands.Int(0, len(this.httpGzipClients)-1)]
}
return nil
}
func (this *RPCClient) Context(adminId int64) context.Context {
ctx := context.Background()
m := maps.Map{