Documentation ¶
Index ¶
- Constants
- Variables
- type KeyFunc
- type MQBroker
- type RPCHandler
- type RabbitMQ
- type RabbitMQConfig
- type RedisRegistry
- type RegisterMQ
- func (tr *RegisterMQ) Close()
- func (tr *RegisterMQ) Connect()
- func (tr *RegisterMQ) ReceiveMessage() (*meim.InternalMessage, error)
- func (tr *RegisterMQ) SendMessage(msg *meim.InternalMessage) error
- func (tr *RegisterMQ) Subscribe(uid int64)
- func (tr *RegisterMQ) SyncMessage(msg *meim.InternalMessage) (*meim.InternalMessage, error)
- func (tr *RegisterMQ) UnSubscribe(uid int64)
- type Registry
Constants ¶
View Source
const ( ChannelPub = 1 << iota ChannelSub ChannelRPC ChannelRPCServer AllChannel = ChannelPub | ChannelSub | ChannelRPC | ChannelRPCServer )
Variables ¶
View Source
var (
ErrorUserNodeNotFound = errors.New("user node not found")
)
Functions ¶
This section is empty.
Types ¶
type MQBroker ¶
type MQBroker interface { Node() int ReceiveMessage() *meim.InternalMessage SendMessage(node int, msg *meim.InternalMessage) error SyncMessage(node int, msg *meim.InternalMessage) (*meim.InternalMessage, error) Close() }
type RPCHandler ¶
type RPCHandler func(*meim.InternalMessage) *meim.InternalMessage
type RabbitMQ ¶
type RabbitMQ struct {
// contains filtered or unexported fields
}
一个rabbit完整的Broker
func NewRabbitMQ ¶
func NewRabbitMQ(cfg *RabbitMQConfig, dc meim.DataCreator, rpcHandler RPCHandler) *RabbitMQ
新建rabbot通道,参数需要给定
func (*RabbitMQ) SendMessage ¶
func (rb *RabbitMQ) SendMessage(node int, msg *meim.InternalMessage) error
异步发送消息 异步发送消息
func (*RabbitMQ) SyncMessage ¶
func (rb *RabbitMQ) SyncMessage(node int, msg *meim.InternalMessage) (*meim.InternalMessage, error)
rpc 服务调用 同步发送等待返回
type RabbitMQConfig ¶
type RabbitMQConfig struct { Node int Url string ExchangeName string ExchangeKind string ChanSize int Channels uint64 RPCTimeout time.Duration SendTimeout time.Duration QueuePrefix string // 队列前缀 }
rabbit配置
type RedisRegistry ¶
type RedisRegistry struct {
// contains filtered or unexported fields
}
Redis注册
func NewRedisRegistry ¶
func NewRedisRegistry(client *redis.Client, key string) *RedisRegistry
func NewRedisRegistry2 ¶
func NewRedisRegistry2(address, password string, db int, key string) *RedisRegistry
func (*RedisRegistry) Close ¶
func (r *RedisRegistry) Close()
func (*RedisRegistry) DeRegister ¶
func (r *RedisRegistry) DeRegister(uid int64)
func (*RedisRegistry) GetUserNode ¶
func (r *RedisRegistry) GetUserNode(uid int64) int
func (*RedisRegistry) Register ¶
func (r *RedisRegistry) Register(uid int64, node int)
TODO 允许web端和手机端同时登录,通过禁用web端某些功能保证业务一致性 暂时只是允许单点登录
type RegisterMQ ¶
type RegisterMQ struct {
// contains filtered or unexported fields
}
Register-Broker
func NewRegisterMQ ¶
func NewRegisterMQ(reg Registry, mq MQBroker) *RegisterMQ
func (*RegisterMQ) Close ¶
func (tr *RegisterMQ) Close()
func (*RegisterMQ) Connect ¶
func (tr *RegisterMQ) Connect()
func (*RegisterMQ) ReceiveMessage ¶
func (tr *RegisterMQ) ReceiveMessage() (*meim.InternalMessage, error)
func (*RegisterMQ) SendMessage ¶
func (tr *RegisterMQ) SendMessage(msg *meim.InternalMessage) error
func (*RegisterMQ) Subscribe ¶
func (tr *RegisterMQ) Subscribe(uid int64)
func (*RegisterMQ) SyncMessage ¶
func (tr *RegisterMQ) SyncMessage(msg *meim.InternalMessage) (*meim.InternalMessage, error)
func (*RegisterMQ) UnSubscribe ¶
func (tr *RegisterMQ) UnSubscribe(uid int64)
Click to show internal directories.
Click to hide internal directories.