serverconnector

package
v1.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventHandler

type EventHandler interface {
	// OnServiceUpdate 回调函数接口
	// 返回缓存值是否已经被清理(对于服务被剔除,或者首次服务拉取失败,会返回true)
	OnServiceUpdate(*ServiceEvent)
	// GetRevision 获取缓存版本号
	GetRevision() string
	// GetBusiness 获取业务
	GetBusiness() string
}

EventHandler 事件回调handler

type MessageCallBack

type MessageCallBack interface {
	// OnResponse 收到应答后回调
	OnResponse(proto.Message)
}

MessageCallBack stream模式的PB消息回调

type Proxy

type Proxy struct {
	ServerConnector
	// contains filtered or unexported fields
}

Proxy is a plugin that proxy requests to a remote server.

func (*Proxy) DeRegisterServiceHandler

func (p *Proxy) DeRegisterServiceHandler(key *model.ServiceEventKey) error

DeRegisterServiceHandler proxy ServerConnector DeRegisterServiceHandler

func (*Proxy) Heartbeat

func (p *Proxy) Heartbeat(instance *model.InstanceHeartbeatRequest) error

Heartbeat proxy ServerConnector Heartbeat

func (*Proxy) RegisterInstance

func (p *Proxy) RegisterInstance(req *model.InstanceRegisterRequest, header map[string]string) (*model.InstanceRegisterResponse, error)

RegisterInstance proxy ServerConnector RegisterInstance

func (*Proxy) RegisterServiceHandler

func (p *Proxy) RegisterServiceHandler(handler *ServiceEventHandler) error

RegisterServiceHandler proxy ServerConnector RegisterServiceHandler

func (*Proxy) ReportClient

func (p *Proxy) ReportClient(req *model.ReportClientRequest) (*model.ReportClientResponse, error)

ReportClient proxy ServerConnector ReportClient

func (*Proxy) SetRealPlugin

func (p *Proxy) SetRealPlugin(plug plugin.Plugin, engine model.Engine)

SetRealPlugin 设置

func (*Proxy) UpdateServers

func (p *Proxy) UpdateServers(key *model.ServiceEventKey) error

UpdateServers proxy ServerConnector UpdateServers

type ServerConnector

type ServerConnector interface {
	plugin.Plugin
	// RegisterServiceHandler 注册服务监听器
	// 异常场景:当key不合法或者sdk已经退出过程中,则返回error
	RegisterServiceHandler(*ServiceEventHandler) error
	// DeRegisterServiceHandler 反注册事件监听器
	// 异常场景:当sdk已经退出过程中,则返回error
	DeRegisterServiceHandler(*model.ServiceEventKey) error
	// RegisterInstance 同步注册服务
	RegisterInstance(req *model.InstanceRegisterRequest, header map[string]string) (*model.InstanceRegisterResponse, error)
	// DeregisterInstance 同步反注册服务
	DeregisterInstance(instance *model.InstanceDeRegisterRequest) error
	// Heartbeat 心跳上报
	Heartbeat(instance *model.InstanceHeartbeatRequest) error
	// ReportClient 上报客户端信息
	// 异常场景:当sdk已经退出过程中,则返回error
	// 异常场景:当服务端不可用或者上报失败,则返回error,调用者需进行重试
	ReportClient(*model.ReportClientRequest) (*model.ReportClientResponse, error)
	// UpdateServers 更新服务端地址
	// 异常场景:当地址列表为空,或者地址全部连接失败,则返回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
}

ServiceEventHandler 服务事件回调结构

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL