Documentation ¶
Index ¶
- Constants
- Variables
- type ContactRepo
- func (repo *ContactRepo) CreateNotExists(logHead string, params *model.BuildContactParams) (contact *model.Contact, err error)
- func (repo *ContactRepo) Edit(logHead string, tx *query.Query, row *model.Contact) (err error)
- func (repo *ContactRepo) Info(logHead string, ownerId *gen_id.ComponentId, peerId *gen_id.ComponentId) (row *model.Contact, err error)
- func (repo *ContactRepo) InfoWithCache(ownerId *gen_id.ComponentId, peerId *gen_id.ComponentId) (*model.Contact, error)
- func (repo *ContactRepo) RangeList(logHead string, params *model.FetchContactRangeParams) (list []*model.Contact, err error)
- func (repo *ContactRepo) TableName(ownerId uint64) (dbName string, tbName string)
- func (repo *ContactRepo) UpdateLastDelMsg(logHead string, lastDelMsgId model.BigIntType, versionId uint64, ...) (affectedRow int64, err error)
- func (repo *ContactRepo) UpdateLastMsgId(ctx context.Context, logHead string, contactId uint64, ...) (err error)
- type Data
- func (d *Data) GetServerIds(ctx context.Context, tcpSessionIds []string) (res []string, err error)
- func (d *Data) GetSessionByUserIds(ctx context.Context, userIds []uint64) (res map[string]string, err error)
- func (d *Data) KafkaSendToAll(req *request.SendToAllReq) (err error)
- func (d *Data) KafkaSendToRoom(req *request.SendToRoomReq) (err error)
- func (d *Data) KafkaSendToUsers(serverId string, tcpSessionIds []string, subId int32, msg []byte) (err error)
- func (d *Data) SessionBinding(ctx context.Context, logHead string, rr *pb.ConnectCommon, ...) (err error)
- func (d *Data) SessionDel(ctx context.Context, logHead string, rr *pb.ConnectCommon) (has bool, err error)
- func (d *Data) SessionLease(ctx context.Context, logHead string, rr *pb.ConnectCommon, ...) (has bool, err error)
- type MessageRepo
- func (repo *MessageRepo) Create(logHead string, row *model.Message) (err error)
- func (repo *MessageRepo) DecrUnreadAfterFetch(ctx context.Context, logHead string, ownerId, peerId *gen_id.ComponentId, ...) (err error)
- func (repo *MessageRepo) GetTotalUnread(ctx context.Context, logHead string, id *gen_id.ComponentId) (val int64, err error)
- func (repo *MessageRepo) IncrUnreadAfterSend(ctx context.Context, logHead string, receiverId, senderId *gen_id.ComponentId, ...) (err error)
- func (repo *MessageRepo) Info(msgId uint64) (row *model.Message, err error)
- func (repo *MessageRepo) InfoWithCache(msgId uint64) (*model.Message, error)
- func (repo *MessageRepo) MGetSessionUnread(ctx context.Context, logHead string, id1 *gen_id.ComponentId, ...) (retMap map[string]int64, err error)
- func (repo *MessageRepo) RangeList(params *model.FetchMsgRangeParams) (list []*model.Message, err error)
- func (repo *MessageRepo) TableName(id uint64) (dbName string, tbName string)
- func (repo *MessageRepo) TableNameByContactId(id1, id2 *gen_id.ComponentId) (dbName string, tbName string)
- func (repo *MessageRepo) UpdateMsgVerAndStatus(logHead string, msgId, versionId model.BigIntType, status model.MsgStatus) (err error)
Constants ¶
View Source
const ( KeySessionUnreadExpire = 86400 * 15 KeyTotalUnreadExpire = 86400 * 15 )
View Source
const (
KeyExpire = 3600
)
Variables ¶
View Source
var ProviderSet = wire.NewSet(NewContactRepo, NewMessageRepo, NewData)
ProviderSet is data providers.
Functions ¶
This section is empty.
Types ¶
type ContactRepo ¶
type ContactRepo struct {
*Data
}
func NewContactRepo ¶
func NewContactRepo(data *Data) *ContactRepo
func (*ContactRepo) CreateNotExists ¶
func (repo *ContactRepo) CreateNotExists(logHead string, params *model.BuildContactParams) (contact *model.Contact, err error)
CreateNotExists 创建会话
func (*ContactRepo) Info ¶
func (repo *ContactRepo) Info(logHead string, ownerId *gen_id.ComponentId, peerId *gen_id.ComponentId) (row *model.Contact, err error)
Info 查询某个会话的信息
func (*ContactRepo) InfoWithCache ¶
func (repo *ContactRepo) InfoWithCache(ownerId *gen_id.ComponentId, peerId *gen_id.ComponentId) (*model.Contact, error)
InfoWithCache 查询某个会话的信息
func (*ContactRepo) RangeList ¶
func (repo *ContactRepo) RangeList(logHead string, params *model.FetchContactRangeParams) (list []*model.Contact, err error)
RangeList 获取一定范围的会话列表
func (*ContactRepo) TableName ¶
func (repo *ContactRepo) TableName(ownerId uint64) (dbName string, tbName string)
func (*ContactRepo) UpdateLastDelMsg ¶
func (repo *ContactRepo) UpdateLastDelMsg(logHead string, lastDelMsgId model.BigIntType, versionId uint64, ownerId *gen_id.ComponentId, peerId *gen_id.ComponentId) (affectedRow int64, err error)
UpdateLastDelMsg 更新contact的最后一条已删除的消息(清空聊天记录)
func (*ContactRepo) UpdateLastMsgId ¶
func (repo *ContactRepo) UpdateLastMsgId(ctx context.Context, logHead string, contactId uint64, ownerId *gen_id.ComponentId, lastMsgId uint64, peerAck model.PeerAckStatus) (err error)
UpdateLastMsgId 更新contact的最后一条消息(发消息)
type Data ¶
type Data struct { RedisClient *redis.Client MySQLClient *gorm.DB Db *query.Query KafkaProducer kafka.SyncProducer // contains filtered or unexported fields }
func (*Data) GetServerIds ¶
GetServerIds 获取TcpSessionId对应的ServerId
func (*Data) GetSessionByUserIds ¶
func (d *Data) GetSessionByUserIds(ctx context.Context, userIds []uint64) (res map[string]string, err error)
GetSessionByUserIds 获取用户ID对应的Session信息
func (*Data) KafkaSendToAll ¶
func (d *Data) KafkaSendToAll(req *request.SendToAllReq) (err error)
func (*Data) KafkaSendToRoom ¶
func (d *Data) KafkaSendToRoom(req *request.SendToRoomReq) (err error)
func (*Data) KafkaSendToUsers ¶
func (*Data) SessionBinding ¶
func (d *Data) SessionBinding(ctx context.Context, logHead string, rr *pb.ConnectCommon, expire time.Duration) (err error)
SessionBinding KEY绑定
func (*Data) SessionDel ¶
func (d *Data) SessionDel(ctx context.Context, logHead string, rr *pb.ConnectCommon) (has bool, err error)
SessionDel KEY删除
type MessageRepo ¶
type MessageRepo struct {
*Data
}
func NewMessageRepo ¶
func NewMessageRepo(data *Data) *MessageRepo
func (*MessageRepo) Create ¶
func (repo *MessageRepo) Create(logHead string, row *model.Message) (err error)
func (*MessageRepo) DecrUnreadAfterFetch ¶
func (repo *MessageRepo) DecrUnreadAfterFetch(ctx context.Context, logHead string, ownerId, peerId *gen_id.ComponentId, decr int64) (err error)
DecrUnreadAfterFetch 获取消息后,清空未读数
func (*MessageRepo) GetTotalUnread ¶
func (repo *MessageRepo) GetTotalUnread(ctx context.Context, logHead string, id *gen_id.ComponentId) (val int64, err error)
GetTotalUnread 获取未读数(总未读数)
func (*MessageRepo) IncrUnreadAfterSend ¶
func (repo *MessageRepo) IncrUnreadAfterSend(ctx context.Context, logHead string, receiverId, senderId *gen_id.ComponentId, incr int64) (err error)
IncrUnreadAfterSend 发送消息后,增加未读数
func (*MessageRepo) Info ¶
func (repo *MessageRepo) Info(msgId uint64) (row *model.Message, err error)
Info 查询某条消息的详情
func (*MessageRepo) InfoWithCache ¶
func (repo *MessageRepo) InfoWithCache(msgId uint64) (*model.Message, error)
InfoWithCache 查询某条消息的详情
func (*MessageRepo) MGetSessionUnread ¶
func (repo *MessageRepo) MGetSessionUnread(ctx context.Context, logHead string, id1 *gen_id.ComponentId, id2Arr []*gen_id.ComponentId) (retMap map[string]int64, err error)
MGetSessionUnread 获取未读数(会话未读数)
func (*MessageRepo) RangeList ¶
func (repo *MessageRepo) RangeList(params *model.FetchMsgRangeParams) (list []*model.Message, err error)
RangeList 获取一定范围的消息列表
func (*MessageRepo) TableName ¶
func (repo *MessageRepo) TableName(id uint64) (dbName string, tbName string)
TableName 因为msgId和largerId的后4位是相同的,所以这里传入msgId或者largerId都可以
func (*MessageRepo) TableNameByContactId ¶
func (repo *MessageRepo) TableNameByContactId(id1, id2 *gen_id.ComponentId) (dbName string, tbName string)
func (*MessageRepo) UpdateMsgVerAndStatus ¶
func (repo *MessageRepo) UpdateMsgVerAndStatus(logHead string, msgId, versionId model.BigIntType, status model.MsgStatus) (err error)
UpdateMsgVerAndStatus 修改某条消息的状态
Source Files ¶
Click to show internal directories.
Click to hide internal directories.