Documentation ¶
Index ¶
Constants ¶
View Source
const ( //短连接模式 ConnectionShort int = iota //长连接模式 ConnectionLong )
Variables ¶
View Source
var ( //不同系统服务使用不同的连接持有模式 DefaultServerServiceToConnectionControl = map[config.ClusterType]int{ config.DiscoverCluster: ConnectionLong, config.HealthCheckCluster: ConnectionShort, config.MonitorCluster: ConnectionShort, } )
Functions ¶
Types ¶
type ClientInfo ¶
当前客户端相关信息
type ConnCreator ¶
type ConnCreator interface { //插件名 Name() string //创建实际的连接 CreateConnection(address string, timeout time.Duration, clientInfo *ClientInfo) (ClosableConn, error) }
连接创建器
type ConnID ¶
type ConnID struct { //唯一ID ID uint32 //所属服务 Service config.ClusterService //目标server地址 Address string // contains filtered or unexported fields }
连接标识
type Connection ¶
type Connection struct { ConnID //连接实体 Conn ClosableConn // contains filtered or unexported fields }
GRPC连接对象,含唯一连接ID
func (*Connection) ForceClose ¶
func (c *Connection) ForceClose() bool
type ConnectionManager ¶
type ConnectionManager interface { // SetConnCreator 设置当前协议的连接创建器 SetConnCreator(creator ConnCreator) // Destroy 销毁并释放连接管理器 Destroy() // GetConnection 获取并占用连接 GetConnection(opKey string, clusterType config.ClusterType) (*Connection, error) // GetConnectionByHashKey 通过传入一致性hashKey的方式获取链接 GetConnectionByHashKey(opKey string, clusterType config.ClusterType, hashKey []byte) (*Connection, error) // ReportConnectionDown 报告连接故障 ReportConnectionDown(connID ConnID) // ReportSuccess 上报接口调用成功 ReportSuccess(connID ConnID, retCode int32, timeout time.Duration) // ReportFail 上报接口调用失败 ReportFail(connID ConnID, retCode int32, timeout time.Duration) // UpdateServers 更新服务地址 UpdateServers(svcEventKey model.ServiceEventKey) // GetClientInfo 获取当前客户端信息 GetClientInfo() *ClientInfo // IsReady discover服务是否已经就绪 IsReady() bool // GetHashExpectedInstance 计算hash Key对应的实例 GetHashExpectedInstance(clusterType config.ClusterType, hash []byte) (string, model.Instance, error) // ConnectByAddr 直接通过addr连接,慎使用 ConnectByAddr(clusterType config.ClusterType, addr string, instance model.Instance) (*Connection, error) }
通用的连接管理器
func NewConnectionManager ¶
func NewConnectionManager( cfg config.Configuration, valueCtx model.ValueContext) (ConnectionManager, error)
创建连接管理器
type ServerAddressList ¶
type ServerAddressList struct {
// contains filtered or unexported fields
}
服务地址列表
func (*ServerAddressList) ConnectServerByAddrOnly ¶
func (s *ServerAddressList) ConnectServerByAddrOnly(addr string, timeout time.Duration, clsService config.ClusterService, instance model.Instance) (*Connection, error)
Click to show internal directories.
Click to hide internal directories.