Documentation ¶
Index ¶
- type EventHandler
- type MessageCallBack
- type Proxy
- func (p *Proxy) DeRegisterServiceHandler(key *model.ServiceEventKey) error
- func (p *Proxy) Heartbeat(instance *model.InstanceHeartbeatRequest) error
- func (p *Proxy) RegisterInstance(req *model.InstanceRegisterRequest) (*model.InstanceRegisterResponse, error)
- func (p *Proxy) RegisterServiceHandler(handler *ServiceEventHandler) error
- func (p *Proxy) ReportClient(req *model.ReportClientRequest) (*model.ReportClientResponse, error)
- func (p *Proxy) SetRealPlugin(plug plugin.Plugin, engine model.Engine)
- func (p *Proxy) UpdateServers(key *model.ServiceEventKey) error
- type ServerConnector
- type ServiceEvent
- type ServiceEventHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventHandler ¶
type EventHandler interface { //回调函数接口 //返回缓存值是否已经被清理(对于服务被剔除,或者首次服务拉取失败,会返回true) OnServiceUpdate(*ServiceEvent) (deleted bool) //获取缓存版本号 GetRevision() string //获取网格请求的resource GetMeshResource() *namingpb.MeshResource GetMeshConfig() *namingpb.MeshConfig //获取业务 GetBusiness() string }
EventHandler 事件回调handler
type MessageCallBack ¶
stream模式的PB消息回调
type Proxy ¶
type Proxy struct { ServerConnector // contains filtered or unexported fields }
proxy of ServerConnector
func (*Proxy) DeRegisterServiceHandler ¶
func (p *Proxy) DeRegisterServiceHandler(key *model.ServiceEventKey) error
proxy ServerConnector DeRegisterServiceHandler
func (*Proxy) Heartbeat ¶
func (p *Proxy) Heartbeat(instance *model.InstanceHeartbeatRequest) error
proxy ServerConnector Heartbeat
func (*Proxy) RegisterInstance ¶
func (p *Proxy) RegisterInstance(req *model.InstanceRegisterRequest) (*model.InstanceRegisterResponse, error)
proxy ServerConnector RegisterInstance
func (*Proxy) RegisterServiceHandler ¶
func (p *Proxy) RegisterServiceHandler(handler *ServiceEventHandler) error
proxy ServerConnector RegisterServiceHandler
func (*Proxy) ReportClient ¶
func (p *Proxy) ReportClient(req *model.ReportClientRequest) (*model.ReportClientResponse, error)
proxy ServerConnector ReportClient
func (*Proxy) SetRealPlugin ¶
设置
func (*Proxy) UpdateServers ¶
func (p *Proxy) UpdateServers(key *model.ServiceEventKey) error
proxy ServerConnector UpdateServers
type ServerConnector ¶
type ServerConnector interface { plugin.Plugin //注册服务监听器 //异常场景:当key不合法或者sdk已经退出过程中,则返回error RegisterServiceHandler(*ServiceEventHandler) error //反注册事件监听器 //异常场景:当sdk已经退出过程中,则返回error DeRegisterServiceHandler(*model.ServiceEventKey) error //同步注册服务 RegisterInstance(*model.InstanceRegisterRequest) (*model.InstanceRegisterResponse, error) // 同步反注册服务 DeregisterInstance(instance *model.InstanceDeRegisterRequest) error // 心跳上报 Heartbeat(instance *model.InstanceHeartbeatRequest) error // 上报客户端信息 // 异常场景:当sdk已经退出过程中,则返回error // 异常场景:当服务端不可用或者上报失败,则返回error,调用者需进行重试 ReportClient(*model.ReportClientRequest) (*model.ReportClientResponse, error) // 更新服务端地址 // 异常场景:当地址列表为空,或者地址全部连接失败,则返回error,调用者需进行重试 UpdateServers(key *model.ServiceEventKey) error }
ServerConnector 【扩展点接口】server代理,封装了server对接的逻辑
type ServiceEvent ¶
type ServiceEvent struct { //服务 model.ServiceEventKey //事件对象值 Value proto.Message //服务错误 Error model.SDKError }
ServiceEvent 事件对象
type ServiceEventHandler ¶
type ServiceEventHandler struct { *model.ServiceEventKey //目标发现集群,对于系统服务,需要使用默认集群来进行发现 TargetCluster config.ClusterType //服务的定期刷新时间,默认1s RefreshInterval time.Duration //服务事件处理句柄 Handler EventHandler }
服务事件回调结构
Click to show internal directories.
Click to hide internal directories.