Documentation ¶
Index ¶
- Constants
- Variables
- func Gcd(a uint32, b uint32) uint32
- func GetConfigPath(server *Server) string
- func GetConfigVersionPath(server *Server) string
- func GetConfigsPath(server *Server) string
- func GetNodeName(server *Server) string
- func GetNodePath(server *Server) string
- func GetNodesPath(server *Server) string
- func GetRouterConfigPath(server *Server) string
- func GetServiceKey(serviceName string, protocol string, routerId int64, shardType string, ...) int64
- func GetServices(server *Server) string
- func IpToInt(ip string) uint32
- type Action
- type BalanceLocalFirstConfig
- type ClientOption
- type CloseThriftClient
- type ConfigSubscriber
- type Conn
- type ConnGroup
- type ConsulRegistry
- func (cr *ConsulRegistry) Available(server Server) error
- func (cr *ConsulRegistry) DisableStatic(serviceName string) error
- func (cr *ConsulRegistry) Discover(serviceName string)
- func (cr *ConsulRegistry) EnableStatic(serviceName string) error
- func (cr *ConsulRegistry) GetAllSubscribed() []string
- func (cr *ConsulRegistry) GetConfig(serviceName string)
- func (cr *ConsulRegistry) GetValue(key string) (string, bool)
- func (cr *ConsulRegistry) PushStaticNodes(serviceName string, serverList ServerList) error
- func (cr *ConsulRegistry) PutRouterConfig(server Server, config ServiceRouterConfig) error
- func (cr *ConsulRegistry) PutServiceConfigs(server Server, configs map[string]string) error
- func (cr *ConsulRegistry) RegisterServer(server Server) error
- func (cr *ConsulRegistry) SubscribeConfig(serviceName string, subscriber ConfigSubscriber)
- func (cr *ConsulRegistry) SubscribeService(serviceName string, subscriber ServiceSubscriber)
- func (cr *ConsulRegistry) Unavailable(server Server) error
- func (cr *ConsulRegistry) UnregisterConfig(server Server) error
- func (cr *ConsulRegistry) UnregisterServer(server Server) error
- func (cr *ConsulRegistry) UnsubscribeConfig(serviceName string)
- func (cr *ConsulRegistry) UnsubscribeService(serviceName string)
- type ConsulServiceConfigPull
- type ConsulServiceInfoPull
- type ConsulServicePush
- type CurrentStateWrapper
- type Done
- type DoneFunc
- type LoadBalance
- type LoadBalanceConfigurableWeight
- type LoadBalanceIpRangeFirst
- type LoadBalanceLocalFirst
- type LoadBalanceRandom
- type LoadBalanceRoundrobin
- type LoadBalanceStaticWeight
- type Multiplexer
- type NewThriftClient
- type OnError
- type OnSuccess
- type Pool
- type PoolOption
- type Registry
- type Router
- func (router *Router) BatchDiscover(option ClientOption, routerIds []int64) map[int64]*Server
- func (router *Router) ConfigNotify(serviceName string, serviceConfig ServiceConfig)
- func (router *Router) Discover(option ClientOption) (*Server, bool)
- func (router *Router) GetAllSubscribed() http.Handler
- func (router *Router) GetConfigs(name string) (map[string]string, bool)
- func (router *Router) GetCounter(server *Server) tally.Counter
- func (router *Router) GetMetrics() tally.Scope
- func (router *Router) GetOrCreateBalancer(option ClientOption) LoadBalance
- func (router *Router) GetOrCreateConfigPuller(serviceName string) *ServicePuller
- func (router *Router) GetOrCreateDiscoverPuller(serviceName string) *ServicePuller
- func (router *Router) GetOrCreateServicePusher(server Server) *ServicePusher
- func (router *Router) GetRegistry() Registry
- func (router *Router) GetRouterDb() RouterDb
- func (router *Router) GetServerList(option ClientOption) (ServerList, bool)
- func (router *Router) GetServiceRouterConfig(serviceName string) (*ServiceRouterConfig, bool)
- func (router *Router) PushStaticNodes() http.Handler
- func (router *Router) RegisterServer(server Server)
- func (router *Router) RestartTimerHandler() http.Handler
- func (router *Router) SetRouterDb(db RouterDb)
- func (router *Router) StaticSwitch() http.Handler
- type RouterConfig
- type RouterDb
- type RouterDbImpl
- func (rd *RouterDbImpl) BatchSelectServers(serviceName, protocol string, routerIds []int64, shardType string, dc string) map[int64]ServerList
- func (rd *RouterDbImpl) ConfigNotify(serviceName string, serviceConfig ServiceConfig)
- func (rd *RouterDbImpl) GetConfigs() map[string]ServiceConfig
- func (rd *RouterDbImpl) GetServiceConfig(serviceName string) (map[string]string, bool)
- func (rd *RouterDbImpl) GetServiceRouterConfig(serviceName string) ServiceRouterConfig
- func (rd *RouterDbImpl) PickServers(serviceName string, serviceList ServerList) ServerList
- func (rd *RouterDbImpl) SelectServers(serviceName string, protocol string, routerId int64, shardType string, ...) (ServerList, bool)
- func (rd *RouterDbImpl) ServiceNotify(serviceName string, services ServerList)
- func (rd *RouterDbImpl) UpdateConfig(serviceName string, config ServiceConfig)
- func (rd *RouterDbImpl) UpdateServers(serviceName string, serverList ServerList)
- type Server
- type ServerAddress
- type ServerList
- type ServiceConfig
- type ServicePull
- type ServicePuller
- type ServicePush
- type ServicePusher
- func (sh *ServicePusher) Reload(ttl time.Duration)
- func (sh *ServicePusher) Restart()
- func (sh *ServicePusher) SetAvailableShardList(shardList []uint32)
- func (sh *ServicePusher) SetFollowerAvailableShardList(shardList []uint32)
- func (sh *ServicePusher) SetFollowerShardList(shardList []uint32)
- func (sh *ServicePusher) SetIsEdgeNode(isEdgeNode bool)
- func (sh *ServicePusher) SetPartitionList(partition_list []int64)
- func (sh *ServicePusher) SetShardList(shardList []uint32)
- func (sh *ServicePusher) SetStatus(status string)
- func (sh *ServicePusher) SetWeight(weight uint32)
- func (sh *ServicePusher) Start(ctx context.Context)
- func (sh *ServicePusher) Stop()
- type ServiceRouterConfig
- type ServiceSubscriber
- type Then
- type ThriftClient
- type ThriftCompressionMethod
- type ThriftConfig
- type ThriftConn
- type ThriftIsOpen
- type ThriftTransportType
Constants ¶
View Source
const ( PREFIX = "ads_core_go" NAMESPACE = "service_router" ROUTER_VERSION = "service_router_version" ROUTER_MAJOR_VERSION = "major_version" ROUTER_MINOR_VERSION = "minor_version" ROUTER_REVISION = "revision" ROUTER_METRICS_SELECT_ADDRESS = "select_address" ROUTER_METRICS_SELECT_ADDRESS_TAGS_ADDR = "addr" ROUTER_METRICS_SELECT_ADDRESS_TAGS_ADDR_VAL_NONE = "none" POOL_METRICS_AQUIRE_BLOCKED = "pool_aquire_blocked" POOL_IDLE_CONNECTIONS = "pool_idle_connections" POOL_ACTIVE_CONNECTIONS = "pool_active_connections" METRICS_URI = "/ads-core/metrics" PROMETHEUS_URI = "/ads-core/metrics/prometheus" RESTART_TIMER = "/ads-core/timer/restart" HTTP_SERVER_SUBSCRIBED = "/ads-core/router/subscribed" HTTP_SERVER_ROUTER_STATIC_SWITCH = "/ads-core/router/static_switch" HTTP_SERVER_ROUTER_PUT_NODES = "/ads-core/router/put_nodes" )
View Source
const ( CONSUL_REGISTRY_KV_PREFIX string = "ads-core/services/" CONSUL_REGISTRY_KV_NODES string = "/nodes/" CONSUL_REGISTRY_KV_CONFIG string = "/config/" CONSUL_REGISTRY_KV_CONFIG_ROUTER string = "router" CONSUL_REGISTRY_KV_CONFIG_CONFIGS string = "configs/" CONSUL_REGISTRY_KV_CONFIG_VERSION string = "version" CONSUL_REGISTRY_KV_KEY_SPLIT string = ":" )
View Source
const ( ServerProtocol_HTTP = "http" ServerProtocol_THRIFT = "thrift" ServerProtocol_REDIS = "redis" )
服务协议
View Source
const ( ServerStatus_AVAILABLE = "available" ServerStatus_UNAVAILABLE = "unavailable" ServerStatus_UNKNOWN = "unknown" )
服务状态
View Source
const ( LoadBalanceMethod_RANDOM = "random" LoadBalanceMethod_ROUNDROBIN = "roundrobin" LoadBalanceMethod_LOCALFIRST = "localfirst" LoadBalanceMethod_CONSISTENT = "consistent" LoadBalanceMethod_CONFIGURABLE_WEIGHT = "configurable_weight" LoadBalanceMethod_ACTIVE_WEIGHT = "active_weight" LoadBalanceMethod_USER_DEFINED = "user_defined" LoadBalanceMethod_IPRANGEFIRST = "iprangefirst" LoadBalanceMethod_STATIC_WEIGHT = "static_weight" )
View Source
const ( ShardType_ALL = "0" ShardType_LEADER = "1" ShardType_FOLLOWER = "2" )
View Source
const ( ServicePullerType_Config = "CONFIG_PULLER" ServicePullerType_Server = "SERVER_PULLER" )
View Source
const (
DEFAULT_DC = "default"
)
View Source
const UINT32MAX int64 = 4294967295 // 2^32 - 1
Variables ¶
View Source
var (
ErrInvalidServer = errors.New("invalid server")
)
View Source
var (
ErrPoolExhausted = errors.New("connection pool exhausted")
)
View Source
var SupportedLoadBalanceMethod = map[string]bool{ LoadBalanceMethod_RANDOM: true, LoadBalanceMethod_ROUNDROBIN: true, LoadBalanceMethod_LOCALFIRST: true, LoadBalanceMethod_CONSISTENT: false, LoadBalanceMethod_CONFIGURABLE_WEIGHT: true, LoadBalanceMethod_ACTIVE_WEIGHT: false, LoadBalanceMethod_IPRANGEFIRST: true, LoadBalanceMethod_STATIC_WEIGHT: true, LoadBalanceMethod_USER_DEFINED: false, }
Functions ¶
func GetConfigPath ¶
func GetConfigVersionPath ¶
func GetConfigsPath ¶
func GetNodeName ¶
func GetNodePath ¶
func GetNodesPath ¶
func GetRouterConfigPath ¶
func GetServiceKey ¶
func GetServices ¶
Types ¶
type BalanceLocalFirstConfig ¶
func DefaultBalanceLocalFirstConfig ¶
func DefaultBalanceLocalFirstConfig() BalanceLocalFirstConfig
Get default BalanceLocalFirstConfig
type ClientOption ¶
type ClientOption struct { ServiceName string ShardId int64 ShardType string Protocol string Loadbalance string TargetServerAddress ServerAddress UserBalance LoadBalance LocalFirstConfig BalanceLocalFirstConfig PartitionHash int64 RouteToEdgeNode bool Idc string Dc string }
func ClientOptionFactory ¶
func ClientOptionFactory(serviceName string, protocol string) ClientOption
type CloseThriftClient ¶
type CloseThriftClient func(client ThriftClient) error
type ConfigSubscriber ¶
type ConfigSubscriber interface {
ConfigNotify(serviceName string, serviceConfig ServiceConfig)
}
ConfigSubscriber interface
type ConnGroup ¶
func GetConnGroup ¶
func GetConnGroup() *ConnGroup
func (*ConnGroup) GetConnection ¶
func (cg *ConnGroup) GetConnection( config ThriftConfig, opts ...PoolOption, ) (Conn, error)
type ConsulRegistry ¶
type ConsulRegistry struct {
// contains filtered or unexported fields
}
ConsulRegistry class
func NewConsulRegistry ¶
func NewConsulRegistry(config *api.Config) (*ConsulRegistry, error)
Constructor
func (*ConsulRegistry) Available ¶
func (cr *ConsulRegistry) Available(server Server) error
func (*ConsulRegistry) DisableStatic ¶
func (cr *ConsulRegistry) DisableStatic(serviceName string) error
func (*ConsulRegistry) Discover ¶
func (cr *ConsulRegistry) Discover(serviceName string)
ConsulRegistry::discover
func (*ConsulRegistry) EnableStatic ¶
func (cr *ConsulRegistry) EnableStatic(serviceName string) error
func (*ConsulRegistry) GetAllSubscribed ¶
func (cr *ConsulRegistry) GetAllSubscribed() []string
func (*ConsulRegistry) GetConfig ¶
func (cr *ConsulRegistry) GetConfig(serviceName string)
ConsulRegistry::getConfig
func (*ConsulRegistry) PushStaticNodes ¶
func (cr *ConsulRegistry) PushStaticNodes(serviceName string, serverList ServerList) error
func (*ConsulRegistry) PutRouterConfig ¶
func (cr *ConsulRegistry) PutRouterConfig(server Server, config ServiceRouterConfig) error
func (*ConsulRegistry) PutServiceConfigs ¶
func (cr *ConsulRegistry) PutServiceConfigs(server Server, configs map[string]string) error
func (*ConsulRegistry) RegisterServer ¶
func (cr *ConsulRegistry) RegisterServer(server Server) error
func (*ConsulRegistry) SubscribeConfig ¶
func (cr *ConsulRegistry) SubscribeConfig(serviceName string, subscriber ConfigSubscriber)
subscribe config
func (*ConsulRegistry) SubscribeService ¶
func (cr *ConsulRegistry) SubscribeService(serviceName string, subscriber ServiceSubscriber)
subscribe service
func (*ConsulRegistry) Unavailable ¶
func (cr *ConsulRegistry) Unavailable(server Server) error
func (*ConsulRegistry) UnregisterConfig ¶
func (cr *ConsulRegistry) UnregisterConfig(server Server) error
func (*ConsulRegistry) UnregisterServer ¶
func (cr *ConsulRegistry) UnregisterServer(server Server) error
func (*ConsulRegistry) UnsubscribeConfig ¶
func (cr *ConsulRegistry) UnsubscribeConfig(serviceName string)
func (*ConsulRegistry) UnsubscribeService ¶
func (cr *ConsulRegistry) UnsubscribeService(serviceName string)
type ConsulServiceConfigPull ¶
type ConsulServiceConfigPull struct {
// contains filtered or unexported fields
}
func GetConsulServiceConfigPull ¶
func GetConsulServiceConfigPull(registry Registry) *ConsulServiceConfigPull
func (*ConsulServiceConfigPull) Pull ¶
func (scp *ConsulServiceConfigPull) Pull(serviceName string)
type ConsulServiceInfoPull ¶
type ConsulServiceInfoPull struct {
// contains filtered or unexported fields
}
func GetConsulServiceInfoPull ¶
func GetConsulServiceInfoPull(registry Registry) *ConsulServiceInfoPull
singleton
func (*ConsulServiceInfoPull) Pull ¶
func (sip *ConsulServiceInfoPull) Pull(serviceName string)
type ConsulServicePush ¶
type ConsulServicePush struct {
// contains filtered or unexported fields
}
func NewConsulServicePush ¶
func NewConsulServicePush(registry Registry) *ConsulServicePush
func (*ConsulServicePush) Push ¶
func (csp *ConsulServicePush) Push(server Server) error
type CurrentStateWrapper ¶
type CurrentStateWrapper struct {
// contains filtered or unexported fields
}
type LoadBalance ¶
type LoadBalance interface {
Select(serverList ServerList) (*Server, bool)
}
LoadBalance interface
type LoadBalanceConfigurableWeight ¶
LoadBalanceConfigurableWeight
func NewLoadBalanceConfigurableWeight ¶
func NewLoadBalanceConfigurableWeight() *LoadBalanceConfigurableWeight
func (*LoadBalanceConfigurableWeight) Select ¶
func (bcw *LoadBalanceConfigurableWeight) Select(serverList ServerList) (*Server, bool)
type LoadBalanceIpRangeFirst ¶
type LoadBalanceIpRangeFirst struct {
// contains filtered or unexported fields
}
LoadBalanceIpRangeFirst
func NewLoadBalanceIpRangeFirst ¶
func NewLoadBalanceIpRangeFirst(config BalanceLocalFirstConfig) *LoadBalanceIpRangeFirst
func (*LoadBalanceIpRangeFirst) Select ¶
func (lbirf *LoadBalanceIpRangeFirst) Select(serverList ServerList) (*Server, bool)
type LoadBalanceLocalFirst ¶
type LoadBalanceLocalFirst struct {
// contains filtered or unexported fields
}
LoadBalanceLocalFirst
func NewLoadBalanceLocalFirst ¶
func NewLoadBalanceLocalFirst(config BalanceLocalFirstConfig) *LoadBalanceLocalFirst
func (*LoadBalanceLocalFirst) Select ¶
func (lblf *LoadBalanceLocalFirst) Select(serverList ServerList) (*Server, bool)
type LoadBalanceRandom ¶
type LoadBalanceRandom struct { }
LoadBalanceRandom
func NewLoadBalanceRandom ¶
func NewLoadBalanceRandom() *LoadBalanceRandom
func (*LoadBalanceRandom) Select ¶
func (lbr *LoadBalanceRandom) Select(serverList ServerList) (*Server, bool)
type LoadBalanceRoundrobin ¶
type LoadBalanceRoundrobin struct {
// contains filtered or unexported fields
}
LoadBalanceRoundrobin
func NewLoadBalanceRoundrobin ¶
func NewLoadBalanceRoundrobin() *LoadBalanceRoundrobin
func (*LoadBalanceRoundrobin) Select ¶
func (lbrr *LoadBalanceRoundrobin) Select(serverList ServerList) (*Server, bool)
type LoadBalanceStaticWeight ¶
type LoadBalanceStaticWeight struct { }
LoadBalanceStaticWeight
func NewLoadBalanceStaticWeight ¶
func NewLoadBalanceStaticWeight() *LoadBalanceStaticWeight
func (*LoadBalanceStaticWeight) Select ¶
func (lbsw *LoadBalanceStaticWeight) Select(serverList ServerList) (*Server, bool)
type Multiplexer ¶
type NewThriftClient ¶
type NewThriftClient func(thrift.Transport, thrift.ProtocolFactory) ThriftClient
type Pool ¶
type Pool struct { sync.Mutex Factory func() (Conn, error) MaxIdle int // Maximum number of idle connections in the pool MaxActive int // Maximum number of connections allocated by the pool, MaxActive >= MaxIdle IdleTimeout time.Duration Wait bool Metric tally.Scope // contains filtered or unexported fields }
type PoolOption ¶
type PoolOption func(*poolOptions)
func PoolIdleTimeout ¶
func PoolIdleTimeout(t time.Duration) PoolOption
func PoolMaxActive ¶
func PoolMaxActive(n int) PoolOption
func PoolMaxIdle ¶
func PoolMaxIdle(n int) PoolOption
func PoolMetric ¶
func PoolMetric(m tally.Scope) PoolOption
func PoolWait ¶
func PoolWait(b bool) PoolOption
type Registry ¶
type Registry interface { SubscribeService(serviceName string, subscriber ServiceSubscriber) UnsubscribeService(serviceName string) SubscribeConfig(serviceName string, subscriber ConfigSubscriber) UnsubscribeConfig(serviceName string) Discover(serviceName string) GetConfig(serviceName string) GetValue(key string) (string, bool) PutRouterConfig(server Server, config ServiceRouterConfig) error PutServiceConfigs(server Server, config map[string]string) error RegisterServer(server Server) error UnregisterServer(server Server) error UnregisterConfig(server Server) error Available(server Server) error GetAllSubscribed() []string PushStaticNodes(serviceName string, serverList ServerList) error EnableStatic(serviceName string) error DisableStatic(serviceName string) error }
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) BatchDiscover ¶
func (router *Router) BatchDiscover(option ClientOption, routerIds []int64) map[int64]*Server
通过shardIds批量发现
func (*Router) ConfigNotify ¶
func (router *Router) ConfigNotify(serviceName string, serviceConfig ServiceConfig)
update timer
func (*Router) GetAllSubscribed ¶
func (*Router) GetMetrics ¶
func (*Router) GetOrCreateBalancer ¶
func (router *Router) GetOrCreateBalancer(option ClientOption) LoadBalance
func (*Router) GetOrCreateConfigPuller ¶
func (router *Router) GetOrCreateConfigPuller(serviceName string) *ServicePuller
func (*Router) GetOrCreateDiscoverPuller ¶
func (router *Router) GetOrCreateDiscoverPuller(serviceName string) *ServicePuller
func (*Router) GetOrCreateServicePusher ¶
func (router *Router) GetOrCreateServicePusher(server Server) *ServicePusher
func (*Router) GetRegistry ¶
func (*Router) GetRouterDb ¶
func (*Router) GetServerList ¶
func (router *Router) GetServerList(option ClientOption) (ServerList, bool)
func (*Router) GetServiceRouterConfig ¶
func (router *Router) GetServiceRouterConfig(serviceName string) (*ServiceRouterConfig, bool)
func (*Router) PushStaticNodes ¶
func (*Router) RegisterServer ¶
func (*Router) RestartTimerHandler ¶
func (*Router) SetRouterDb ¶
func (*Router) StaticSwitch ¶
type RouterConfig ¶
type RouterDb ¶
type RouterDb interface { ServiceSubscriber ConfigSubscriber GetConfigs() map[string]ServiceConfig GetServiceConfig(serviceName string) (map[string]string, bool) GetServiceRouterConfig(serviceName string) ServiceRouterConfig PickServers(serviceName string, serviceList ServerList) ServerList UpdateServers(serviceName string, serverList ServerList) UpdateConfig(serviceName string, config ServiceConfig) SelectServers(serviceName string, protocol string, routerId int64, shardType string, dc string) (ServerList, bool) BatchSelectServers(serviceName, protocol string, routerIds []int64, shardType string, dc string) map[int64]ServerList }
func GetRouterDb ¶
func GetRouterDb() RouterDb
type RouterDbImpl ¶
type RouterDbImpl struct {
// contains filtered or unexported fields
}
RouterDbImpl所提供的api返回的数据必须是副本 golang没法控制引用的写权限
func (*RouterDbImpl) BatchSelectServers ¶
func (rd *RouterDbImpl) BatchSelectServers(serviceName, protocol string, routerIds []int64, shardType string, dc string) map[int64]ServerList
func (*RouterDbImpl) ConfigNotify ¶
func (rd *RouterDbImpl) ConfigNotify(serviceName string, serviceConfig ServiceConfig)
func (*RouterDbImpl) GetConfigs ¶
func (rd *RouterDbImpl) GetConfigs() map[string]ServiceConfig
func (*RouterDbImpl) GetServiceConfig ¶
func (rd *RouterDbImpl) GetServiceConfig(serviceName string) (map[string]string, bool)
func (*RouterDbImpl) GetServiceRouterConfig ¶
func (rd *RouterDbImpl) GetServiceRouterConfig(serviceName string) ServiceRouterConfig
func (*RouterDbImpl) PickServers ¶
func (rd *RouterDbImpl) PickServers(serviceName string, serviceList ServerList) ServerList
func (*RouterDbImpl) SelectServers ¶
func (rd *RouterDbImpl) SelectServers(serviceName string, protocol string, routerId int64, shardType string, dc string) (ServerList, bool)
func (*RouterDbImpl) ServiceNotify ¶
func (rd *RouterDbImpl) ServiceNotify(serviceName string, services ServerList)
func (*RouterDbImpl) UpdateConfig ¶
func (rd *RouterDbImpl) UpdateConfig(serviceName string, config ServiceConfig)
func (*RouterDbImpl) UpdateServers ¶
func (rd *RouterDbImpl) UpdateServers(serviceName string, serverList ServerList)
type Server ¶
type Server struct { Host string `json:"Host"` Port uint16 `json:"Port"` ServiceName string `json:"ServiceName"` Protocol string `json:"Protocol"` Status string `json:"Status"` UpdateTime uint64 `json:"UpdateTime"` Weight uint32 `json:"Weight"` ShardList []uint32 `json:"ShardList"` AvailableShardList []uint32 `json:"AvailableShardList"` FollowerShardList []uint32 `json:"FollowerShardList"` FollowerAvailableShardList []uint32 `json:"FollowerAvailableShardList"` OtherSettings map[string]string `json:"OtherSettings"` PartitionList []int64 `json:"PartitionList"` IsEdgeNode bool `json:"IsEdgeNode"` Idc string `json:"Idc"` Dc string `json:"Dc"` }
服务
type ServerAddress ¶
type ServerList ¶
type ServerList []Server
type ServiceConfig ¶
type ServiceConfig struct { Router ServiceRouterConfig Configs map[string]string }
type ServicePuller ¶
type ServicePuller struct {
// contains filtered or unexported fields
}
func NewServicePuller ¶
func NewServicePuller(serviceName string, servicePull ServicePull, routerConfig ServiceRouterConfig, pullerType string) *ServicePuller
func (*ServicePuller) Reload ¶
func (sp *ServicePuller) Reload(interval time.Duration)
func (*ServicePuller) Restart ¶
func (sp *ServicePuller) Restart()
func (*ServicePuller) Start ¶
func (sp *ServicePuller) Start(ctx context.Context)
func (*ServicePuller) Stop ¶
func (sp *ServicePuller) Stop()
type ServicePush ¶
type ServicePusher ¶
type ServicePusher struct {
// contains filtered or unexported fields
}
func NewServicePusher ¶
func NewServicePusher(server Server, push ServicePush, routerConfig ServiceRouterConfig) *ServicePusher
func (*ServicePusher) Reload ¶
func (sh *ServicePusher) Reload(ttl time.Duration)
func (*ServicePusher) Restart ¶
func (sh *ServicePusher) Restart()
func (*ServicePusher) SetAvailableShardList ¶
func (sh *ServicePusher) SetAvailableShardList(shardList []uint32)
func (*ServicePusher) SetFollowerAvailableShardList ¶
func (sh *ServicePusher) SetFollowerAvailableShardList(shardList []uint32)
func (*ServicePusher) SetFollowerShardList ¶
func (sh *ServicePusher) SetFollowerShardList(shardList []uint32)
func (*ServicePusher) SetIsEdgeNode ¶
func (sh *ServicePusher) SetIsEdgeNode(isEdgeNode bool)
func (*ServicePusher) SetPartitionList ¶
func (sh *ServicePusher) SetPartitionList(partition_list []int64)
func (*ServicePusher) SetShardList ¶
func (sh *ServicePusher) SetShardList(shardList []uint32)
func (*ServicePusher) SetStatus ¶
func (sh *ServicePusher) SetStatus(status string)
func (*ServicePusher) SetWeight ¶
func (sh *ServicePusher) SetWeight(weight uint32)
func (*ServicePusher) Start ¶
func (sh *ServicePusher) Start(ctx context.Context)
func (*ServicePusher) Stop ¶
func (sh *ServicePusher) Stop()
type ServiceRouterConfig ¶
type ServiceRouterConfig struct { TtlInMs uint32 `json:"TtlInMs" toml:"TtlInMs"` LoadBalanceMethod string `json:"LoadBalance" toml:"LoadBalance"` TotalShards uint32 `json:"TotalShards" toml:"TotalShards"` PullInterval uint32 `json:"PullInterval" toml:"PullInterval"` }
func DefaultServiceRouterConfig ¶
func DefaultServiceRouterConfig() ServiceRouterConfig
Get default ServiceRouterConfig
type ServiceSubscriber ¶
type ServiceSubscriber interface {
ServiceNotify(serviceName string, services ServerList)
}
ServiceSubscriber interface
type ThriftClient ¶
type ThriftClient interface{}
type ThriftCompressionMethod ¶
type ThriftCompressionMethod uint32
const ( ThriftCompressionMethod_None ThriftCompressionMethod = 0 ThriftCompressionMethod_Zlib ThriftCompressionMethod = 1 ThriftCompressionMethod_HMAC ThriftCompressionMethod = 2 ThriftCompressionMethod_Snappy ThriftCompressionMethod = 3 ThriftCompressionMethod_QLZ ThriftCompressionMethod = 3 ThriftCompressionMethod_Zstd ThriftCompressionMethod = 3 )
type ThriftConfig ¶
type ThriftConfig struct { Host string Port int TransportType ThriftTransportType CompressionMethod ThriftCompressionMethod Timeout time.Duration NewThriftClient NewThriftClient CloseThriftClient CloseThriftClient ThriftIsOpen ThriftIsOpen }
type ThriftConn ¶
unthreadsafe 连接池不会把同一个连接同时分配给两个协程, 但是,在获取连接后,不要并发操作连接
func NewThriftConn ¶
func NewThriftConn(config ThriftConfig) (*ThriftConn, error)
func (*ThriftConn) Close ¶
func (tc *ThriftConn) Close() error
func (*ThriftConn) Do ¶
func (tc *ThriftConn) Do(action Action) *Done
func (*ThriftConn) Err ¶
func (tc *ThriftConn) Err() error
func (*ThriftConn) ForceClose ¶
func (tc *ThriftConn) ForceClose() bool
func (*ThriftConn) SetErr ¶
func (tc *ThriftConn) SetErr(err error)
type ThriftIsOpen ¶
type ThriftIsOpen func(client ThriftClient) bool
type ThriftTransportType ¶
type ThriftTransportType string
const ( THRIFT_TRANSPORT_HEADER ThriftTransportType = "HEADER" THRIFT_TRANSPORT_FREMED ThriftTransportType = "FRAMED" THRIFT_TRANSPORT_HTTP2 ThriftTransportType = "HTTP2" // not implemented THRIFT_TRANSPORT_RSOCKET ThriftTransportType = "RSOCKET" // not implemented )
Click to show internal directories.
Click to hide internal directories.