Documentation ¶
Index ¶
- Constants
- type CloseFunc
- type KeepaliveFunc
- type NodeFunc
- type NodeOption
- type OnConnectFunc
- type OnLeaderFunc
- type OnRemoveFunc
- type ReloadFunc
- type SendAllFunc
- type SendRawFunc
- type Service
- type ServiceOption
- type SetProFunc
- type TcpConfig
- type TcpGroupsOptions
- type TcpService
- type TcpServiceOption
Constants ¶
View Source
const ( CMD_SET_PRO = iota // 注册客户端操作,加入到指定分组 CMD_AUTH // 认证(暂未使用) CMD_ERROR // 错误响应 CMD_TICK // 心跳包 CMD_EVENT // 事件 CMD_AGENT CMD_STOP CMD_RELOAD CMD_SHOW_MEMBERS CMD_POS )
View Source
const ( FlagSetPro = iota FlagPing )
View Source
const (
Registered = 1 << iota
)
服务注册
View Source
const ServiceName = "wing-binlog-go-subscribe"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KeepaliveFunc ¶
type KeepaliveFunc func(data []byte)
type NodeOption ¶
type NodeOption func(n *tcpClientNode)
func NodeClose ¶
func NodeClose(f NodeFunc) NodeOption
type OnConnectFunc ¶
type OnLeaderFunc ¶
type OnLeaderFunc func(bool)
type OnRemoveFunc ¶
type ReloadFunc ¶
type ReloadFunc func()
type SendAllFunc ¶
type SendRawFunc ¶
type SendRawFunc func(msg []byte)
type Service ¶
type Service struct { ServiceName string //service name, like: service.add ServiceHost string //service host, like: 0.0.0.0, 127.0.0.1 ServiceIp string // if ServiceHost is 0.0.0.0, ServiceIp must set, // like 127.0.0.1 or 192.168.9.12 or 114.55.56.168 ServicePort int // service port, like: 9998 Interval time.Duration // interval for update ttl Ttl int //check ttl ServiceID string //serviceID = fmt.Sprintf("%s-%s-%d", name, ip, port) Kv *consul.KV // contains filtered or unexported fields }
func NewService ¶
func NewService( host string, port int, consulAddress string, opts ...ServiceOption) *Service
new a service name: service name host: service host like 0.0.0.0 or 127.0.0.1 port: service port, like 9998 consulAddress: consul service address, like 127.0.0.1:8500 opts: ServiceOption, like ServiceIp("127.0.0.1") return new service pointer
func (*Service) Deregister ¶
type ServiceOption ¶
type ServiceOption func(s *Service)
type SetProFunc ¶
type TcpGroupsOptions ¶
type TcpGroupsOptions func(groups *tcpGroups)
func SetOnRemove ¶
func SetOnRemove(f OnRemoveFunc) TcpGroupsOptions
type TcpService ¶
type TcpService struct { service.Service Listen string // 监听ip Enable bool // contains filtered or unexported fields }
func NewSubscribeService ¶
func NewSubscribeService(ctx *app.Context) *TcpService
func (*TcpService) Close ¶
func (tcp *TcpService) Close()
func (*TcpService) Name ¶
func (tcp *TcpService) Name() string
func (*TcpService) Reload ¶
func (tcp *TcpService) Reload()
func (*TcpService) SendAll ¶
func (tcp *TcpService) SendAll(table string, data []byte) bool
send event data to all connects client
func (*TcpService) SendRaw ¶
func (tcp *TcpService) SendRaw(msg []byte) bool
send raw bytes data to all connects client msg is the pack frame form func: pack
func (*TcpService) Start ¶
func (tcp *TcpService) Start()
type TcpServiceOption ¶
type TcpServiceOption func(service *TcpService)
func SetKeepalive ¶
func SetKeepalive(f KeepaliveFunc) TcpServiceOption
func SetOnClose ¶
func SetOnClose(f CloseFunc) TcpServiceOption
func SetOnConnect ¶
func SetOnConnect(f OnConnectFunc) TcpServiceOption
func SetReload ¶
func SetReload(f ReloadFunc) TcpServiceOption
func SetSendAll ¶
func SetSendAll(f SendAllFunc) TcpServiceOption
func SetSendRaw ¶
func SetSendRaw(f SendRawFunc) TcpServiceOption
Click to show internal directories.
Click to hide internal directories.