feat: add redis cache and fanout support

This commit is contained in:
richjohnrambo
2026-08-25 20:54:03 +08:00
parent 07376c70e3
commit f900a08a01
68 changed files with 3949 additions and 5696 deletions
+32 -32
View File
@@ -810,8 +810,8 @@ type SeqRange struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Low int32 `protobuf:"varint,1,opt,name=low,proto3" json:"low,omitempty"`
Hi int32 `protobuf:"varint,2,opt,name=hi,proto3" json:"hi,omitempty"`
Low int64 `protobuf:"varint,1,opt,name=low,proto3" json:"low,omitempty"`
Hi int64 `protobuf:"varint,2,opt,name=hi,proto3" json:"hi,omitempty"`
}
func (x *SeqRange) Reset() {
@@ -846,14 +846,14 @@ func (*SeqRange) Descriptor() ([]byte, []int) {
return file_model_proto_rawDescGZIP(), []int{6}
}
func (x *SeqRange) GetLow() int32 {
func (x *SeqRange) GetLow() int64 {
if x != nil {
return x.Low
}
return 0
}
func (x *SeqRange) GetHi() int32 {
func (x *SeqRange) GetHi() int64 {
if x != nil {
return x.Hi
}
@@ -872,9 +872,9 @@ type GetOpts struct {
// Limit search results to one topic;
Topic string `protobuf:"bytes,3,opt,name=topic,proto3" json:"topic,omitempty"`
// Load messages with seq id equal or greater than this
SinceId int32 `protobuf:"varint,4,opt,name=since_id,json=sinceId,proto3" json:"since_id,omitempty"`
SinceId int64 `protobuf:"varint,4,opt,name=since_id,json=sinceId,proto3" json:"since_id,omitempty"`
// Load messages with seq id lower than this
BeforeId int32 `protobuf:"varint,5,opt,name=before_id,json=beforeId,proto3" json:"before_id,omitempty"`
BeforeId int64 `protobuf:"varint,5,opt,name=before_id,json=beforeId,proto3" json:"before_id,omitempty"`
// Maximum number of results to return
Limit int32 `protobuf:"varint,6,opt,name=limit,proto3" json:"limit,omitempty"`
// Load messages by id or ranges of ids
@@ -934,14 +934,14 @@ func (x *GetOpts) GetTopic() string {
return ""
}
func (x *GetOpts) GetSinceId() int32 {
func (x *GetOpts) GetSinceId() int64 {
if x != nil {
return x.SinceId
}
return 0
}
func (x *GetOpts) GetBeforeId() int32 {
func (x *GetOpts) GetBeforeId() int64 {
if x != nil {
return x.BeforeId
}
@@ -1911,7 +1911,7 @@ type ClientNote struct {
// "kp" - typing notification, "call" - voice/video call
What InfoNote `protobuf:"varint,2,opt,name=what,proto3,enum=pbx.InfoNote" json:"what,omitempty"`
// Server-issued message ID being reported
SeqId int32 `protobuf:"varint,3,opt,name=seq_id,json=seqId,proto3" json:"seq_id,omitempty"`
SeqId int64 `protobuf:"varint,3,opt,name=seq_id,json=seqId,proto3" json:"seq_id,omitempty"`
// Client's count of unread messages to report back to the server. Used in push notifications on iOS.
Unread int32 `protobuf:"varint,4,opt,name=unread,proto3" json:"unread,omitempty"`
// Call event.
@@ -1966,7 +1966,7 @@ func (x *ClientNote) GetWhat() InfoNote {
return InfoNote_X1
}
func (x *ClientNote) GetSeqId() int32 {
func (x *ClientNote) GetSeqId() int64 {
if x != nil {
return x.SeqId
}
@@ -2338,9 +2338,9 @@ type TopicDesc struct {
TouchedAt int64 `protobuf:"varint,3,opt,name=touched_at,json=touchedAt,proto3" json:"touched_at,omitempty"`
Defacs *DefaultAcsMode `protobuf:"bytes,4,opt,name=defacs,proto3" json:"defacs,omitempty"`
Acs *AccessMode `protobuf:"bytes,5,opt,name=acs,proto3" json:"acs,omitempty"`
SeqId int32 `protobuf:"varint,6,opt,name=seq_id,json=seqId,proto3" json:"seq_id,omitempty"`
ReadId int32 `protobuf:"varint,7,opt,name=read_id,json=readId,proto3" json:"read_id,omitempty"`
RecvId int32 `protobuf:"varint,8,opt,name=recv_id,json=recvId,proto3" json:"recv_id,omitempty"`
SeqId int64 `protobuf:"varint,6,opt,name=seq_id,json=seqId,proto3" json:"seq_id,omitempty"`
ReadId int64 `protobuf:"varint,7,opt,name=read_id,json=readId,proto3" json:"read_id,omitempty"`
RecvId int64 `protobuf:"varint,8,opt,name=recv_id,json=recvId,proto3" json:"recv_id,omitempty"`
DelId int32 `protobuf:"varint,9,opt,name=del_id,json=delId,proto3" json:"del_id,omitempty"`
Public []byte `protobuf:"bytes,10,opt,name=public,proto3" json:"public,omitempty"`
Private []byte `protobuf:"bytes,11,opt,name=private,proto3" json:"private,omitempty"`
@@ -2421,21 +2421,21 @@ func (x *TopicDesc) GetAcs() *AccessMode {
return nil
}
func (x *TopicDesc) GetSeqId() int32 {
func (x *TopicDesc) GetSeqId() int64 {
if x != nil {
return x.SeqId
}
return 0
}
func (x *TopicDesc) GetReadId() int32 {
func (x *TopicDesc) GetReadId() int64 {
if x != nil {
return x.ReadId
}
return 0
}
func (x *TopicDesc) GetRecvId() int32 {
func (x *TopicDesc) GetRecvId() int64 {
if x != nil {
return x.RecvId
}
@@ -2522,8 +2522,8 @@ type TopicSub struct {
DeletedAt int64 `protobuf:"varint,2,opt,name=deleted_at,json=deletedAt,proto3" json:"deleted_at,omitempty"`
Online bool `protobuf:"varint,3,opt,name=online,proto3" json:"online,omitempty"`
Acs *AccessMode `protobuf:"bytes,4,opt,name=acs,proto3" json:"acs,omitempty"`
ReadId int32 `protobuf:"varint,5,opt,name=read_id,json=readId,proto3" json:"read_id,omitempty"`
RecvId int32 `protobuf:"varint,6,opt,name=recv_id,json=recvId,proto3" json:"recv_id,omitempty"`
ReadId int64 `protobuf:"varint,5,opt,name=read_id,json=readId,proto3" json:"read_id,omitempty"`
RecvId int64 `protobuf:"varint,6,opt,name=recv_id,json=recvId,proto3" json:"recv_id,omitempty"`
Public []byte `protobuf:"bytes,7,opt,name=public,proto3" json:"public,omitempty"`
Trusted []byte `protobuf:"bytes,16,opt,name=trusted,proto3" json:"trusted,omitempty"` // 16!
Private []byte `protobuf:"bytes,8,opt,name=private,proto3" json:"private,omitempty"`
@@ -2533,7 +2533,7 @@ type TopicSub struct {
Topic string `protobuf:"bytes,10,opt,name=topic,proto3" json:"topic,omitempty"`
TouchedAt int64 `protobuf:"varint,11,opt,name=touched_at,json=touchedAt,proto3" json:"touched_at,omitempty"`
// ID of the last {data} message in a topic
SeqId int32 `protobuf:"varint,12,opt,name=seq_id,json=seqId,proto3" json:"seq_id,omitempty"`
SeqId int64 `protobuf:"varint,12,opt,name=seq_id,json=seqId,proto3" json:"seq_id,omitempty"`
// Messages are deleted up to this ID
DelId int32 `protobuf:"varint,13,opt,name=del_id,json=delId,proto3" json:"del_id,omitempty"`
// Other user's last online timestamp & user agent
@@ -2601,14 +2601,14 @@ func (x *TopicSub) GetAcs() *AccessMode {
return nil
}
func (x *TopicSub) GetReadId() int32 {
func (x *TopicSub) GetReadId() int64 {
if x != nil {
return x.ReadId
}
return 0
}
func (x *TopicSub) GetRecvId() int32 {
func (x *TopicSub) GetRecvId() int64 {
if x != nil {
return x.RecvId
}
@@ -2657,7 +2657,7 @@ func (x *TopicSub) GetTouchedAt() int64 {
return 0
}
func (x *TopicSub) GetSeqId() int32 {
func (x *TopicSub) GetSeqId() int64 {
if x != nil {
return x.SeqId
}
@@ -2833,7 +2833,7 @@ type ServerData struct {
Timestamp int64 `protobuf:"varint,7,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
// Timestamp when the message was deleted or 0. Milliseconds since the epoch 01/01/1970
DeletedAt int64 `protobuf:"varint,3,opt,name=deleted_at,json=deletedAt,proto3" json:"deleted_at,omitempty"`
SeqId int32 `protobuf:"varint,4,opt,name=seq_id,json=seqId,proto3" json:"seq_id,omitempty"`
SeqId int64 `protobuf:"varint,4,opt,name=seq_id,json=seqId,proto3" json:"seq_id,omitempty"`
Head map[string][]byte `protobuf:"bytes,5,rep,name=head,proto3" json:"head,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
Content []byte `protobuf:"bytes,6,opt,name=content,proto3" json:"content,omitempty"`
}
@@ -2898,7 +2898,7 @@ func (x *ServerData) GetDeletedAt() int64 {
return 0
}
func (x *ServerData) GetSeqId() int32 {
func (x *ServerData) GetSeqId() int64 {
if x != nil {
return x.SeqId
}
@@ -2929,7 +2929,7 @@ type ServerPres struct {
Src string `protobuf:"bytes,2,opt,name=src,proto3" json:"src,omitempty"`
What ServerPres_What `protobuf:"varint,3,opt,name=what,proto3,enum=pbx.ServerPres_What" json:"what,omitempty"`
UserAgent string `protobuf:"bytes,4,opt,name=user_agent,json=userAgent,proto3" json:"user_agent,omitempty"`
SeqId int32 `protobuf:"varint,5,opt,name=seq_id,json=seqId,proto3" json:"seq_id,omitempty"`
SeqId int64 `protobuf:"varint,5,opt,name=seq_id,json=seqId,proto3" json:"seq_id,omitempty"`
DelId int32 `protobuf:"varint,6,opt,name=del_id,json=delId,proto3" json:"del_id,omitempty"`
DelSeq []*SeqRange `protobuf:"bytes,7,rep,name=del_seq,json=delSeq,proto3" json:"del_seq,omitempty"`
TargetUserId string `protobuf:"bytes,8,opt,name=target_user_id,json=targetUserId,proto3" json:"target_user_id,omitempty"`
@@ -2997,7 +2997,7 @@ func (x *ServerPres) GetUserAgent() string {
return ""
}
func (x *ServerPres) GetSeqId() int32 {
func (x *ServerPres) GetSeqId() int64 {
if x != nil {
return x.SeqId
}
@@ -3152,7 +3152,7 @@ type ServerInfo struct {
Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"`
FromUserId string `protobuf:"bytes,2,opt,name=from_user_id,json=fromUserId,proto3" json:"from_user_id,omitempty"`
What InfoNote `protobuf:"varint,3,opt,name=what,proto3,enum=pbx.InfoNote" json:"what,omitempty"`
SeqId int32 `protobuf:"varint,4,opt,name=seq_id,json=seqId,proto3" json:"seq_id,omitempty"`
SeqId int64 `protobuf:"varint,4,opt,name=seq_id,json=seqId,proto3" json:"seq_id,omitempty"`
Src string `protobuf:"bytes,5,opt,name=src,proto3" json:"src,omitempty"`
Event CallEvent `protobuf:"varint,6,opt,name=event,proto3,enum=pbx.CallEvent" json:"event,omitempty"`
Payload []byte `protobuf:"bytes,7,opt,name=payload,proto3" json:"payload,omitempty"`
@@ -3211,7 +3211,7 @@ func (x *ServerInfo) GetWhat() InfoNote {
return InfoNote_X1
}
func (x *ServerInfo) GetSeqId() int32 {
func (x *ServerInfo) GetSeqId() int64 {
if x != nil {
return x.SeqId
}
@@ -3862,8 +3862,8 @@ type SubscriptionEvent struct {
Topic string `protobuf:"bytes,2,opt,name=topic,proto3" json:"topic,omitempty"`
UserId string `protobuf:"bytes,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
DelId int32 `protobuf:"varint,4,opt,name=del_id,json=delId,proto3" json:"del_id,omitempty"`
ReadId int32 `protobuf:"varint,5,opt,name=read_id,json=readId,proto3" json:"read_id,omitempty"`
RecvId int32 `protobuf:"varint,6,opt,name=recv_id,json=recvId,proto3" json:"recv_id,omitempty"`
ReadId int64 `protobuf:"varint,5,opt,name=read_id,json=readId,proto3" json:"read_id,omitempty"`
RecvId int64 `protobuf:"varint,6,opt,name=recv_id,json=recvId,proto3" json:"recv_id,omitempty"`
Mode *AccessMode `protobuf:"bytes,7,opt,name=mode,proto3" json:"mode,omitempty"`
Private []byte `protobuf:"bytes,8,opt,name=private,proto3" json:"private,omitempty"`
}
@@ -3928,14 +3928,14 @@ func (x *SubscriptionEvent) GetDelId() int32 {
return 0
}
func (x *SubscriptionEvent) GetReadId() int32 {
func (x *SubscriptionEvent) GetReadId() int64 {
if x != nil {
return x.ReadId
}
return 0
}
func (x *SubscriptionEvent) GetRecvId() int32 {
func (x *SubscriptionEvent) GetRecvId() int64 {
if x != nil {
return x.RecvId
}