实现特殊页面配置

This commit is contained in:
GoEdgeLab
2020-09-20 08:58:48 +08:00
parent b20ab500aa
commit 6fddbc6a33
13 changed files with 400 additions and 3 deletions

View File

@@ -31,6 +31,7 @@ type RPCClient struct {
httpGzipClients []pb.HTTPGzipServiceClient
httpHeaderPolicyClients []pb.HTTPHeaderPolicyServiceClient
httpHeaderClients []pb.HTTPHeaderServiceClient
httpPageClients []pb.HTTPPageServiceClient
}
func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
@@ -51,6 +52,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
httpGzipClients := []pb.HTTPGzipServiceClient{}
httpHeaderPolicyClients := []pb.HTTPHeaderPolicyServiceClient{}
httpHeaderClients := []pb.HTTPHeaderServiceClient{}
httpPageClients := []pb.HTTPPageServiceClient{}
conns := []*grpc.ClientConn{}
for _, endpoint := range apiConfig.RPC.Endpoints {
@@ -79,6 +81,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
httpGzipClients = append(httpGzipClients, pb.NewHTTPGzipServiceClient(conn))
httpHeaderPolicyClients = append(httpHeaderPolicyClients, pb.NewHTTPHeaderPolicyServiceClient(conn))
httpHeaderClients = append(httpHeaderClients, pb.NewHTTPHeaderServiceClient(conn))
httpPageClients = append(httpPageClients, pb.NewHTTPPageServiceClient(conn))
}
return &RPCClient{
@@ -96,6 +99,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
httpGzipClients: httpGzipClients,
httpHeaderPolicyClients: httpHeaderPolicyClients,
httpHeaderClients: httpHeaderClients,
httpPageClients: httpPageClients,
}, nil
}
@@ -190,6 +194,13 @@ func (this *RPCClient) HTTPHeaderPolicyRPC() pb.HTTPHeaderPolicyServiceClient {
return nil
}
func (this *RPCClient) HTTPPageRPC() pb.HTTPPageServiceClient {
if len(this.httpPageClients) > 0 {
return this.httpPageClients[rands.Int(0, len(this.httpPageClients)-1)]
}
return nil
}
func (this *RPCClient) Context(adminId int64) context.Context {
ctx := context.Background()
m := maps.Map{