Documentation ¶
Index ¶
- Constants
- func AppendHeaderWithReqId(header map[string]string, reqID string) map[string]string
- 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 *apiservice.Instance)
- func GetConnErrorCode(err error) int32
- func GetUpdateTaskRequestTime(updateTask *serviceUpdateTask) time.Duration
- func HeartbeatRequestToProto(request *model.InstanceHeartbeatRequest) (pbInstance *apiservice.Instance)
- func NetworkError(connManager network.ConnectionManager, conn *network.Connection, errCode int32, ...) model.SDKError
- func NextCreateConfigFileReqID() string
- func NextDeRegisterInstanceReqID() string
- func NextDiscoverReqID() string
- func NextGetConfigFileReqID() string
- func NextHeartbeatReqID() string
- func NextPublishConfigFileReqID() string
- func NextRateLimitAcquireReqID() string
- func NextRateLimitInitReqID() string
- func NextRegisterInstanceReqID() string
- func NextReportClientReqID() string
- func NextUpdateConfigFileReqID() string
- func NextWatchConfigFilesReqID() string
- func RegisterRequestToProto(request *model.InstanceRegisterRequest) (pbInstance *apiservice.Instance)
- func ReportClientRequestToProto(request *model.ReportClientRequest) (pbInstance *apiservice.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 ¶
const ( OpKeyRegisterInstance = "RegisterInstance" OpKeyDeregisterInstance = "DeregisterInstance" OpKeyInstanceHeartbeat = "InstanceHeartbeat" OpKeyDiscover = "Discover" OpKeyReportClient = "ReportClient" OpKeyRateLimitInit = "RateLimitInit" OpKeyRateLimitAcquire = "RateLimitAcquire" OpKeyRateLimitMetricInit = "RateLimitMetricInit" OpKeyRateLimitMetricReport = "RateLimitMetricReport" OpKeyGetConfigFile = "GetConfigFile" OpKeyWatchConfigFiles = "WatchConfigFiles" OpKeyCreateConfigFile = "CreateConfigFile" OpKeyUpdateConfigFile = "UpdateConfigFile" OpKeyPublishConfigFile = "PublishConfigFile" OpKeyGetConfigGroup = "GetConfigGroup" )
Variables ¶
This section is empty.
Functions ¶
func AppendHeaderWithReqId ¶ added in v1.2.0
func CreateHeaderContext ¶
func CreateHeaderContext(timeout time.Duration, headers map[string]string) (context.Context, context.CancelFunc)
CreateHeaderContext 创建传输grpc头的valueContext
func CreateHeaderContextWithReqId ¶
func CreateHeaderContextWithReqId(timeout time.Duration, reqID string) (context.Context, context.CancelFunc)
CreateHeaderContextWithReqId 创建传输grpc头的valueContext
func DeregisterRequestToProto ¶
func DeregisterRequestToProto(request *model.InstanceDeRegisterRequest) (pbInstance *apiservice.Instance)
DeregisterRequestToProto 将用户反注册请求转化为服务端需要的proto
func GetUpdateTaskRequestTime ¶
GetUpdateTaskRequestTime 获取一个updateTask的请求更新时间
func HeartbeatRequestToProto ¶
func HeartbeatRequestToProto(request *model.InstanceHeartbeatRequest) (pbInstance *apiservice.Instance)
HeartbeatRequestToProto 将用户心跳请转化为服务端需要的proto
func NetworkError ¶
func NetworkError(connManager network.ConnectionManager, conn *network.Connection, errCode int32, err error, startTime time.Time, msg string) model.SDKError
NetworkError 返回网络错误,并回收连接
func NextCreateConfigFileReqID ¶ added in v1.5.5
func NextCreateConfigFileReqID() string
NextCreateConfigFileReqID 生成CreateConfigFile调用的请求Id
func NextDeRegisterInstanceReqID ¶
func NextDeRegisterInstanceReqID() string
NextDeRegisterInstanceReqID 生成RegisterService调用的请求Id
func NextGetConfigFileReqID ¶ added in v1.1.0
func NextGetConfigFileReqID() string
NextGetConfigFileReqID 生成GetConfigFile调用的请求Id
func NextHeartbeatReqID ¶
func NextHeartbeatReqID() string
NextHeartbeatReqID 生成RegisterService调用的请求Id
func NextPublishConfigFileReqID ¶ added in v1.5.5
func NextPublishConfigFileReqID() string
NextPublishConfigFileReqID 生成PublishConfigFile调用的请求Id
func NextRateLimitAcquireReqID ¶
func NextRateLimitAcquireReqID() string
NextRateLimitAcquireReqID 生成RateLimit配额获取调用的请求Id
func NextRateLimitInitReqID ¶
func NextRateLimitInitReqID() string
NextRateLimitInitReqID 生成RateLimit初始化调用的请求Id
func NextRegisterInstanceReqID ¶
func NextRegisterInstanceReqID() string
NextRegisterInstanceReqID 生成RegisterService调用的请求Id
func NextReportClientReqID ¶
func NextReportClientReqID() string
NextReportClientReqID 生成ReportClient调用的请求Id
func NextUpdateConfigFileReqID ¶ added in v1.5.5
func NextUpdateConfigFileReqID() string
NextUpdateConfigFileReqID 生成UpdateConfigFile调用的请求Id
func NextWatchConfigFilesReqID ¶ added in v1.1.0
func NextWatchConfigFilesReqID() string
NextWatchConfigFilesReqID 生成WatchConfigFiles调用的请求Id
func RegisterRequestToProto ¶
func RegisterRequestToProto(request *model.InstanceRegisterRequest) (pbInstance *apiservice.Instance)
RegisterRequestToProto 将用户的API注册请求结构转换成为server端需要的proto结构
func ReportClientRequestToProto ¶
func ReportClientRequestToProto(request *model.ReportClientRequest) (pbInstance *apiservice.Client)
ReportClientRequestToProto 将客户端上报请转化为服务端需要的proto
Types ¶
type ClientFailEvent ¶
type ClientFailEvent struct {
// contains filtered or unexported fields
}
ClientFailEvent 用于recv协程通知send协程关于链路故障的问题
type DiscoverClient ¶
type DiscoverClient interface { // Send 发送服务发现请求 Send(*apiservice.DiscoverRequest) error // Recv 接收服务发现应答 Recv() (*apiservice.DiscoverResponse, error) // CloseSend 发送EOF CloseSend() error }
DiscoverClient 服务发现客户端接口
type DiscoverClientCreator ¶
type DiscoverClientCreator func( reqId string, connection *network.Connection, timeout time.Duration) (DiscoverClient, context.CancelFunc, error)
DiscoverClientCreator 创建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 设置流关闭