完善了服务器上下线,http登录负载均衡下发gate地址

This commit is contained in:
flswld
2022-12-24 16:52:08 +08:00
parent 7e86669628
commit f4614b3df6
16 changed files with 569 additions and 119 deletions

View File

@@ -21,9 +21,18 @@ var _ = nats_go.Version
// 节点服务器注册发现服务
type DiscoveryNATSRPCServer interface {
// 服务器启动注册获取appid
RegisterServer(ctx context.Context, req *RegisterServerReq) (*RegisterServerRsp, error)
// 服务器关闭取消注册
CancelServer(ctx context.Context, req *CancelServerReq) (*NullMsg, error)
// 服务器在线心跳保持
KeepaliveServer(ctx context.Context, req *KeepaliveServerReq) (*NullMsg, error)
// 获取负载最小的服务器的appid
GetServerAppId(ctx context.Context, req *GetServerAppIdReq) (*GetServerAppIdRsp, error)
// 获取区服密钥信息
GetRegionEc2B(ctx context.Context, req *NullMsg) (*RegionEc2B, error)
// 获取负载最小的网关服务器的地址和端口
GetGateServerAddr(ctx context.Context, req *NullMsg) (*GateServerAddr, error)
}
// RegisterDiscoveryNATSRPCServer register Discovery service
@@ -33,9 +42,18 @@ func RegisterDiscoveryNATSRPCServer(server *natsrpc.Server, s DiscoveryNATSRPCSe
// 节点服务器注册发现服务
type DiscoveryNATSRPCClient interface {
// 服务器启动注册获取appid
RegisterServer(ctx context.Context, req *RegisterServerReq, opt ...natsrpc.CallOption) (*RegisterServerRsp, error)
// 服务器关闭取消注册
CancelServer(ctx context.Context, req *CancelServerReq, opt ...natsrpc.CallOption) (*NullMsg, error)
// 服务器在线心跳保持
KeepaliveServer(ctx context.Context, req *KeepaliveServerReq, opt ...natsrpc.CallOption) (*NullMsg, error)
// 获取负载最小的服务器的appid
GetServerAppId(ctx context.Context, req *GetServerAppIdReq, opt ...natsrpc.CallOption) (*GetServerAppIdRsp, error)
// 获取区服密钥信息
GetRegionEc2B(ctx context.Context, req *NullMsg, opt ...natsrpc.CallOption) (*RegionEc2B, error)
// 获取负载最小的网关服务器的地址和端口
GetGateServerAddr(ctx context.Context, req *NullMsg, opt ...natsrpc.CallOption) (*GateServerAddr, error)
}
type _DiscoveryNATSRPCClient struct {
@@ -58,6 +76,16 @@ func (c *_DiscoveryNATSRPCClient) RegisterServer(ctx context.Context, req *Regis
err := c.c.Request(ctx, "RegisterServer", req, rep, opt...)
return rep, err
}
func (c *_DiscoveryNATSRPCClient) CancelServer(ctx context.Context, req *CancelServerReq, opt ...natsrpc.CallOption) (*NullMsg, error) {
rep := &NullMsg{}
err := c.c.Request(ctx, "CancelServer", req, rep, opt...)
return rep, err
}
func (c *_DiscoveryNATSRPCClient) KeepaliveServer(ctx context.Context, req *KeepaliveServerReq, opt ...natsrpc.CallOption) (*NullMsg, error) {
rep := &NullMsg{}
err := c.c.Request(ctx, "KeepaliveServer", req, rep, opt...)
return rep, err
}
func (c *_DiscoveryNATSRPCClient) GetServerAppId(ctx context.Context, req *GetServerAppIdReq, opt ...natsrpc.CallOption) (*GetServerAppIdRsp, error) {
rep := &GetServerAppIdRsp{}
err := c.c.Request(ctx, "GetServerAppId", req, rep, opt...)
@@ -68,3 +96,8 @@ func (c *_DiscoveryNATSRPCClient) GetRegionEc2B(ctx context.Context, req *NullMs
err := c.c.Request(ctx, "GetRegionEc2B", req, rep, opt...)
return rep, err
}
func (c *_DiscoveryNATSRPCClient) GetGateServerAddr(ctx context.Context, req *NullMsg, opt ...natsrpc.CallOption) (*GateServerAddr, error) {
rep := &GateServerAddr{}
err := c.c.Request(ctx, "GetGateServerAddr", req, rep, opt...)
return rep, err
}