Documentation ¶
Index ¶
- Constants
- Variables
- func ContextGet(ctx context.Context, key string) (string, error)
- func ContextSet(ctx context.Context, key, val string) context.Context
- func DecodeInt64(b []byte) int64
- func EncodeInt64(v int64) []byte
- func EncodeKey(args ...int64) []byte
- func MD5(data []byte) []byte
- func PrintVersion()
- func Split(s, sep string) []string
- type EtcdClient
- func (e *EtcdClient) CAS(cmpKey, cmpValue, key, value string) error
- func (e *EtcdClient) CampaignLeader(key, value string) (<-chan bool, chan<- struct{})
- func (e *EtcdClient) Close()
- func (e *EtcdClient) Get(key string) (string, error)
- func (e *EtcdClient) WaitKeyDelete(key string)
- func (e *EtcdClient) WaitKeyPut(key string)
- type MasterClient
- type NotiferClient
- func (n *NotiferClient) Push(msg meta.PushMessage, ids ...meta.PushID) error
- func (n *NotiferClient) RegionSet(begin, end int32) error
- func (n *NotiferClient) Stop()
- func (n *NotiferClient) Subscribe(id int64, device string, token int64, host string) error
- func (n *NotiferClient) UnSubscribe(id int64, device, host string, sid int64) error
- type Regions
- func (r *Regions) Dump() []meta.Region
- func (r *Regions) Get(id int64) (meta.Region, bool)
- func (r *Regions) GetByHost(host string) (meta.Region, error)
- func (r *Regions) Marshal() (b []byte, e error)
- func (r *Regions) Max() (meta.Region, error)
- func (r *Regions) Merge(from, to string) error
- func (r *Regions) Next(host string) (self meta.Region, next meta.Region, err error)
- func (r *Regions) Split(from, to string) (meta.Region, error)
- type RegionsOption
- type Retry
- type RetryOption
- type Version
Constants ¶
View Source
const ( // UserDBPath 用户数据库位置. UserDBPath = "user" // MessageDBPath 消息数据库位置. MessageDBPath = "message" // GroupDBPath 群组数据库位置. GroupDBPath = "group" // FileBlockPath 块文件存储位置 FileBlockPath = "file_block" // FileDBPath 文件索引存储位置 FileDBPath = "file" // MessageLogDBPath 消息记录数据库位置. MessageLogDBPath = "message_log" // UserMessagePrefix 用户消息前缀. UserMessagePrefix = int64(0) //GroupAdminPrefix 群管理员 GroupAdminPrefix = int64(0) //GroupMemberPrefix 群成员 GroupMemberPrefix = int64(1) //GroupInvitePrefix 群邀请消息 GroupInvitePrefix = int64(2) //GroupApplyPrefix 申请入群消息 GroupApplyPrefix = int64(3) // UserLastMessagePrefix 用户最后一个消息ID. UserLastMessagePrefix = int64(1) // UserGroupPrefix 用户组前缀. UserGroupPrefix = int64(2) // UserFriendPrefix 用户好友前缀. UserFriendPrefix = int64(3) // UserIDPrefix 用户前缀. UserIDPrefix = int64(4) // UserRecentContactPrefix 最近联系人或群前缀. UserRecentContactPrefix = int64(5) // NetworkTimeout 超时. NetworkTimeout = time.Second * 3 )
View Source
const ( // ErrorOK 成功 ErrorOK = 0 // ErrorFailure 未知错误 ErrorFailure = 1 // ErrorUserNameFormat 用户名格式错误 ErrorUserNameFormat = 1000 // ErrorUserNameLen 用户名长度错误 ErrorUserNameLen = 1001 // ErrorUserPasswdFormat 用户密码格式错误 ErrorUserPasswdFormat = 1010 // ErrorUserPasswdLen 用户密码长度错误 ErrorUserPasswdLen = 1011 // ErrorUserNickFormat 昵称格式错误 ErrorUserNickFormat = 1020 // ErrorUserNickLen 昵称长度错误 ErrorUserNickLen = 1021 // ErrorGetSession 获取回话失败 ErrorGetSession = 1030 // ErrorMasterNewID 生成ID失败 ErrorMasterNewID = 1031 // ErrorRegister 注册失败 ErrorRegister = 1032 // ErrorOffline 已经离线 ErrorOffline = 1033 // ErrorUpdateUserInfo 更新用户信息失败 ErrorUpdateUserInfo = 1034 // ErrorUpdateUserPasswd 更新用户密码失败 ErrorUpdateUserPasswd = 1035 // ErrorGetUserInfo 获取用户信息失败 ErrorGetUserInfo = 1036 // ErrorAuth 用户认证失败(提示用户名或密码错误) ErrorAuth = 1037 // ErrorSubscribe 消息订阅失败 ErrorSubscribe = 1038 // ErrorUnSubscribe 取消消息订阅失败 ErrorUnSubscribe = 1039 // ErrorNewMessage 发送消息失败 ErrorNewMessage = 1040 // ErrorFriendSelf 不能添加自己为好友 ErrorFriendSelf = 1041 // ErrorAddFriend 添加好友失败 ErrorAddFriend = 1042 // ErrorGetOnlineSession 用户不在线 ErrorGetOnlineSession = 1043 // ErrorLoadFriendList 加载好友列表失败 ErrorLoadFriendList = 1044 // ErrorFindUser 查找用户失败 ErrorFindUser = 1045 // ErrorCreateGroup 创建分组失败 ErrorCreateGroup = 1046 // ErrorLoadGroup 加载群组列表失败 ErrorLoadGroup = 1047 // ErrorUploadFile 上传文件失败 ErrorUploadFile = 1048 // ErrorCheckFile 文件检查失败 ErrorCheckFile = 1049 // ErrorDownloadFile 下载文件失败 ErrorDownloadFile = 1050 // ErrorLoadMessage 加载消息列表失败 ErrorLoadMessage = 1051 // ErrorUpdateSignature 更新签名失败 ErrorUpdateSignature = 1052 )
View Source
const ( // EtcdMasterKey master key prefix. EtcdMasterKey = "/master" // EtcdMasterAddrKey master addr key. EtcdMasterAddrKey = EtcdMasterKey + "/addr" )
Variables ¶
View Source
var ( // GitTime git log中记录的提交时间. GitTime = "" // GitMessage git log 中记录的提交信息. GitMessage = "" )
View Source
var ( // ErrInvalidContext 从context中解析客户端地址时出错. ErrInvalidContext = errors.New("invalid context") )
View Source
var ( //ErrMasterNotFound 未找到master. ErrMasterNotFound = errors.New("etcd master host not found") )
View Source
var ( //ErrRegionNotFound region not exist. ErrRegionNotFound = errors.New("region not found") )
Functions ¶
func ContextGet ¶
ContextGet get value from context's metadata.
func ContextSet ¶
ContextSet set value to context's metadata.
Types ¶
type EtcdClient ¶
type EtcdClient struct {
// contains filtered or unexported fields
}
EtcdClient etcd client.
func NewEtcdClient ¶
func NewEtcdClient(addrs []string) (*EtcdClient, error)
NewEtcdClient new etcd client.
func (*EtcdClient) CAS ¶
func (e *EtcdClient) CAS(cmpKey, cmpValue, key, value string) error
CAS put value to etcd.
func (*EtcdClient) CampaignLeader ¶
func (e *EtcdClient) CampaignLeader(key, value string) (<-chan bool, chan<- struct{})
CampaignLeader 竞争leader 返回状态只读的chan与关闭只写的chan state如果状态变化则通知, stop外部关闭则停止keepalive
func (*EtcdClient) Get ¶
func (e *EtcdClient) Get(key string) (string, error)
Get get value from etcd.
func (*EtcdClient) WaitKeyDelete ¶
func (e *EtcdClient) WaitKeyDelete(key string)
WaitKeyDelete 等待Key被删除
type MasterClient ¶
MasterClient 连接master服务.
func NewMasterClient ¶
func NewMasterClient(host string, etcdAddrs []string) (*MasterClient, error)
NewMasterClient 返回master client.
type NotiferClient ¶
type NotiferClient struct {
// contains filtered or unexported fields
}
NotiferClient 连接Notifer服务.
func NewNotiferClient ¶
func NewNotiferClient(host string) (*NotiferClient, error)
NewNotiferClient 返回NotiferClient client.
func (*NotiferClient) Push ¶
func (n *NotiferClient) Push(msg meta.PushMessage, ids ...meta.PushID) error
Push 为store提供调用Notifer发推送消息
func (*NotiferClient) RegionSet ¶
func (n *NotiferClient) RegionSet(begin, end int32) error
RegionSet 为master提供,调用Notifer修改所负责的region
func (*NotiferClient) UnSubscribe ¶
func (n *NotiferClient) UnSubscribe(id int64, device, host string, sid int64) error
UnSubscribe 为gate提供,调用Notifer取消订阅消息
type Regions ¶
type Regions struct {
// contains filtered or unexported fields
}
Regions 保存region的路由信息.
type RegionsOption ¶
RegionsOption Regions option.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.