Documentation ¶
Index ¶
- Constants
- func CreateHeaderContext(timeout time.Duration, headers map[string]string) (context.Context, context.CancelFunc)
- func CreateHeaderContextWithReqId(timeout time.Duration, reqID string) (context.Context, context.CancelFunc)
- func DeregisterRequestToProto(request *model.InstanceDeRegisterRequest) (pbInstance *namingpb.Instance)
- func GetConnErrorCode(err error) int32
- func GetUpdateTaskRequestTime(updateTask *serviceUpdateTask) time.Duration
- func HeartbeatRequestToProto(request *model.InstanceHeartbeatRequest) (pbInstance *namingpb.Instance)
- func NetworkError(connManager network.ConnectionManager, conn *network.Connection, errCode int32, ...) model.SDKError
- func NextDeRegisterInstanceReqID() string
- func NextDiscoverReqID() string
- func NextGetConfigFileReqID() string
- func NextHeartbeatReqID() string
- func NextRateLimitAcquireReqID() string
- func NextRateLimitInitReqID() string
- func NextRegisterInstanceReqID() string
- func NextReportClientReqID() string
- func NextWatchConfigFilesReqID() string
- func RegisterRequestToProto(request *model.InstanceRegisterRequest) (pbInstance *namingpb.Instance)
- func ReportClientRequestToProto(request *model.ReportClientRequest) (pbInstance *namingpb.Client)
- type ClientFailEvent
- type DiscoverClient
- type DiscoverClientCreator
- type DiscoverConnector
- func (g *DiscoverConnector) DeRegisterServiceHandler(key *model.ServiceEventKey) error
- func (g *DiscoverConnector) Destroy() error
- func (g *DiscoverConnector) Init(ctx *plugin.InitContext, createClient DiscoverClientCreator)
- func (g *DiscoverConnector) RegisterServiceHandler(svcEventHandler *serverconnector.ServiceEventHandler) error
- func (g *DiscoverConnector) StartUpdateRoutines()
- func (g *DiscoverConnector) UpdateServers(key *model.ServiceEventKey) error
- type StreamingClient
Constants ¶
View Source
const ( OpKeyRegisterInstance = "RegisterInstance" OpKeyDeregisterInstance = "DeregisterInstance" OpKeyInstanceHeartbeat = "InstanceHeartbeat" OpKeyDiscover = "Discover" OpKeyReportClient = "ReportClient" OpKeyRateLimitInit = "RateLimitInit" OpKeyRateLimitAcquire = "RateLimitAcquire" OpKeyRateLimitMetricInit = "RateLimitMetricInit" OpKeyRateLimitMetricReport = "RateLimitMetricReport" OpKeyGetConfigFile = "GetConfigFile" OpKeyWatchConfigFiles = "WatchConfigFiles" )
Variables ¶
This section is empty.
Functions ¶
func CreateHeaderContext ¶
func CreateHeaderContext(timeout time.Duration, headers map[string]string) (context.Context, context.CancelFunc)
创建传输grpc头的valueContext
func CreateHeaderContextWithReqId ¶
func CreateHeaderContextWithReqId(timeout time.Duration, reqID string) (context.Context, context.CancelFunc)
创建传输grpc头的valueContext
func DeregisterRequestToProto ¶
func DeregisterRequestToProto(request *model.InstanceDeRegisterRequest) (pbInstance *namingpb.Instance)
将用户反注册请求转化为服务端需要的proto
func GetUpdateTaskRequestTime ¶
获取一个updateTask的请求更新时间
func HeartbeatRequestToProto ¶
func HeartbeatRequestToProto(request *model.InstanceHeartbeatRequest) (pbInstance *namingpb.Instance)
将用户心跳请转化为服务端需要的proto
func NetworkError ¶
func NetworkError(connManager network.ConnectionManager, conn *network.Connection, errCode int32, err error, startTime time.Time, msg string) model.SDKError
返回网络错误,并回收连接
func NextDeRegisterInstanceReqID ¶
func NextDeRegisterInstanceReqID() string
生成RegisterService调用的请求Id
func RegisterRequestToProto ¶
func RegisterRequestToProto(request *model.InstanceRegisterRequest) (pbInstance *namingpb.Instance)
将用户的API注册请求结构转换成为server端需要的proto结构
func ReportClientRequestToProto ¶
func ReportClientRequestToProto(request *model.ReportClientRequest) (pbInstance *namingpb.Client)
将客户端上报请转化为服务端需要的proto
Types ¶
type ClientFailEvent ¶
type ClientFailEvent struct {
// contains filtered or unexported fields
}
ClientFailEvent 用于recv协程通知send协程关于链路故障的问题
type DiscoverClient ¶
type DiscoverClient interface { // 发送服务发现请求 Send(*namingpb.DiscoverRequest) error // 接收服务发现应答 Recv() (*namingpb.DiscoverResponse, error) // 发送EOF CloseSend() error }
服务发现客户端接口
type DiscoverClientCreator ¶
type DiscoverClientCreator func( reqId string, connection *network.Connection, timeout time.Duration) (DiscoverClient, context.CancelFunc, error)
创建client的函数
type DiscoverConnector ¶
type DiscoverConnector struct { *common.RunContext ServiceConnector *plugin.PluginBase // contains filtered or unexported fields }
DiscoverConnector cl5服务端代理,使用GRPC协议对接
func (*DiscoverConnector) DeRegisterServiceHandler ¶
func (g *DiscoverConnector) DeRegisterServiceHandler(key *model.ServiceEventKey) error
DeRegisterServiceHandler 反注册事件监听器 异常场景:当sdk已经退出过程中,则返回error
func (*DiscoverConnector) Destroy ¶
func (g *DiscoverConnector) Destroy() error
Destroy 销毁插件,可用于释放资源
func (*DiscoverConnector) Init ¶
func (g *DiscoverConnector) Init(ctx *plugin.InitContext, createClient DiscoverClientCreator)
Init 初始化插件
func (*DiscoverConnector) RegisterServiceHandler ¶
func (g *DiscoverConnector) RegisterServiceHandler(svcEventHandler *serverconnector.ServiceEventHandler) error
RegisterServiceHandler 注册服务监听器 异常场景:当key不合法或者sdk已经退出过程中,则返回error
func (*DiscoverConnector) StartUpdateRoutines ¶
func (g *DiscoverConnector) StartUpdateRoutines()
StartUpdateRoutines 初始化connector调度主协程
func (*DiscoverConnector) UpdateServers ¶
func (g *DiscoverConnector) UpdateServers(key *model.ServiceEventKey) error
UpdateServers 更新服务端地址 异常场景:当地址列表为空,或者地址全部连接失败,则返回error,调用者需进行重试
type StreamingClient ¶
type StreamingClient struct {
// contains filtered or unexported fields
}
StreamingClient 流式客户端,带连接
func (*StreamingClient) CloseStream ¶
func (s *StreamingClient) CloseStream(closeSend bool) bool
CloseStream 关闭流并释放连接
func (*StreamingClient) IsEndStream ¶
func (s *StreamingClient) IsEndStream() bool
IsEndStream 设置流关闭
Click to show internal directories.
Click to hide internal directories.