feat: add redis cache and fanout support
This commit is contained in:
+23
-23
@@ -27,9 +27,9 @@ type MsgGetOpts struct {
|
||||
// Return results modified since this timespamp.
|
||||
IfModifiedSince *time.Time `json:"ims,omitempty"`
|
||||
// Load messages/ranges with IDs equal or greater than this (inclusive or closed).
|
||||
SinceId int `json:"since,omitempty"`
|
||||
SinceId int64 `json:"since,omitempty"`
|
||||
// Load messages/ranges with IDs lower than this (exclusive or open).
|
||||
BeforeId int `json:"before,omitempty"`
|
||||
BeforeId int64 `json:"before,omitempty"`
|
||||
// Limit the number of messages loaded.
|
||||
Limit int `json:"limit,omitempty"`
|
||||
// Fetch messages with IDs in these ranges.
|
||||
@@ -100,8 +100,8 @@ type MsgSetQuery struct {
|
||||
// MsgRange is either an individual ID (HiId=0) or a randge of IDs, low end inclusive (closed),
|
||||
// high-end exclusive (open): [LowId .. HiId), e.g. 1..5 -> 1, 2, 3, 4.
|
||||
type MsgRange struct {
|
||||
LowId int `json:"low,omitempty"`
|
||||
HiId int `json:"hi,omitempty"`
|
||||
LowId int64 `json:"low,omitempty"`
|
||||
HiId int64 `json:"hi,omitempty"`
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
@@ -321,7 +321,7 @@ type MsgClientNote struct {
|
||||
// what is being reported: "recv" - message received, "read" - message read, "kp" - typing notification
|
||||
What string `json:"what"`
|
||||
// Server-issued message ID being reported
|
||||
SeqId int `json:"seq,omitempty"`
|
||||
SeqId int64 `json:"seq,omitempty"`
|
||||
// Client's count of unread messages to report back to the server. Used in push notifications on iOS.
|
||||
Unread int `json:"unread,omitempty"`
|
||||
// Call event.
|
||||
@@ -453,9 +453,9 @@ type MsgTopicDesc struct {
|
||||
// Actual access mode
|
||||
Acs *MsgAccessMode `json:"acs,omitempty"`
|
||||
// Max message ID
|
||||
SeqId int `json:"seq,omitempty"`
|
||||
ReadSeqId int `json:"read,omitempty"`
|
||||
RecvSeqId int `json:"recv,omitempty"`
|
||||
SeqId int64 `json:"seq,omitempty"`
|
||||
ReadSeqId int64 `json:"read,omitempty"`
|
||||
RecvSeqId int64 `json:"recv,omitempty"`
|
||||
// Id of the last delete operation as seen by the requesting user
|
||||
DelId int `json:"clear,omitempty"`
|
||||
SubCnt int `json:"subcnt,omitempty"`
|
||||
@@ -475,13 +475,13 @@ func (src *MsgTopicDesc) describe() string {
|
||||
s += " acs={" + src.Acs.describe() + "}"
|
||||
}
|
||||
if src.SeqId != 0 {
|
||||
s += " seq=" + strconv.Itoa(src.SeqId)
|
||||
s += " seq=" + strconv.FormatInt(src.SeqId, 10)
|
||||
}
|
||||
if src.ReadSeqId != 0 {
|
||||
s += " read=" + strconv.Itoa(src.ReadSeqId)
|
||||
s += " read=" + strconv.FormatInt(src.ReadSeqId, 10)
|
||||
}
|
||||
if src.RecvSeqId != 0 {
|
||||
s += " recv=" + strconv.Itoa(src.RecvSeqId)
|
||||
s += " recv=" + strconv.FormatInt(src.RecvSeqId, 10)
|
||||
}
|
||||
if src.DelId != 0 {
|
||||
s += " clear=" + strconv.Itoa(src.DelId)
|
||||
@@ -517,9 +517,9 @@ type MsgTopicSub struct {
|
||||
// Acs.Mode = want & given. The field is not a pointer because at least one value is always assigned.
|
||||
Acs MsgAccessMode `json:"acs,omitempty"`
|
||||
// ID of the message reported by the given user as read
|
||||
ReadSeqId int `json:"read,omitempty"`
|
||||
ReadSeqId int64 `json:"read,omitempty"`
|
||||
// ID of the message reported by the given user as received
|
||||
RecvSeqId int `json:"recv,omitempty"`
|
||||
RecvSeqId int64 `json:"recv,omitempty"`
|
||||
// Topic's public data
|
||||
Public any `json:"public,omitempty"`
|
||||
// Topic's trusted public data
|
||||
@@ -540,7 +540,7 @@ type MsgTopicSub struct {
|
||||
// Timestamp of the last message in the topic.
|
||||
TouchedAt *time.Time `json:"touched,omitempty"`
|
||||
// ID of the last {data} message in a topic
|
||||
SeqId int `json:"seq,omitempty"`
|
||||
SeqId int64 `json:"seq,omitempty"`
|
||||
// Id of the latest Delete operation
|
||||
DelId int `json:"clear,omitempty"`
|
||||
// Number of subscribers, group topics only.
|
||||
@@ -555,13 +555,13 @@ func (src *MsgTopicSub) describe() string {
|
||||
s := src.Topic + ":" + src.User + " online=" + strconv.FormatBool(src.Online) + " acs=" + src.Acs.describe()
|
||||
|
||||
if src.SeqId != 0 {
|
||||
s += " seq=" + strconv.Itoa(src.SeqId)
|
||||
s += " seq=" + strconv.FormatInt(src.SeqId, 10)
|
||||
}
|
||||
if src.ReadSeqId != 0 {
|
||||
s += " read=" + strconv.Itoa(src.ReadSeqId)
|
||||
s += " read=" + strconv.FormatInt(src.ReadSeqId, 10)
|
||||
}
|
||||
if src.RecvSeqId != 0 {
|
||||
s += " recv=" + strconv.Itoa(src.RecvSeqId)
|
||||
s += " recv=" + strconv.FormatInt(src.RecvSeqId, 10)
|
||||
}
|
||||
if src.DelId != 0 {
|
||||
s += " clear=" + strconv.Itoa(src.DelId)
|
||||
@@ -621,7 +621,7 @@ type MsgServerData struct {
|
||||
From string `json:"from,omitempty"`
|
||||
Timestamp time.Time `json:"ts"`
|
||||
DeletedAt *time.Time `json:"deleted,omitempty"`
|
||||
SeqId int `json:"seq"`
|
||||
SeqId int64 `json:"seq"`
|
||||
Head map[string]any `json:"head,omitempty"`
|
||||
Content any `json:"content"`
|
||||
}
|
||||
@@ -636,7 +636,7 @@ func (src *MsgServerData) copy() *MsgServerData {
|
||||
}
|
||||
|
||||
func (src *MsgServerData) describe() string {
|
||||
s := src.Topic + " from=" + src.From + " seq=" + strconv.Itoa(src.SeqId)
|
||||
s := src.Topic + " from=" + src.From + " seq=" + strconv.FormatInt(src.SeqId, 10)
|
||||
if src.DeletedAt != nil {
|
||||
s += " deleted"
|
||||
} else {
|
||||
@@ -654,7 +654,7 @@ type MsgServerPres struct {
|
||||
Src string `json:"src,omitempty"`
|
||||
What string `json:"what"`
|
||||
UserAgent string `json:"ua,omitempty"`
|
||||
SeqId int `json:"seq,omitempty"`
|
||||
SeqId int64 `json:"seq,omitempty"`
|
||||
DelId int `json:"clear,omitempty"`
|
||||
DelSeq []MsgRange `json:"delseq,omitempty"`
|
||||
AcsTarget string `json:"tgt,omitempty"`
|
||||
@@ -706,7 +706,7 @@ func (src *MsgServerPres) describe() string {
|
||||
s += " ua=" + src.UserAgent
|
||||
}
|
||||
if src.SeqId != 0 {
|
||||
s += " seq=" + strconv.Itoa(src.SeqId)
|
||||
s += " seq=" + strconv.FormatInt(src.SeqId, 10)
|
||||
}
|
||||
if src.DelId != 0 {
|
||||
s += " clear=" + strconv.Itoa(src.DelId)
|
||||
@@ -799,7 +799,7 @@ type MsgServerInfo struct {
|
||||
// The event being reported: "rcpt" - message received, "read" - message read, "kp" - typing notification, "call" - video call.
|
||||
What string `json:"what"`
|
||||
// Server-issued message ID being reported.
|
||||
SeqId int `json:"seq,omitempty"`
|
||||
SeqId int64 `json:"seq,omitempty"`
|
||||
// Call event.
|
||||
Event string `json:"event,omitempty"`
|
||||
// Arbitrary json payload (used by video calls).
|
||||
@@ -829,7 +829,7 @@ func (src *MsgServerInfo) describe() string {
|
||||
}
|
||||
s += " what=" + src.What + " from=" + src.From
|
||||
if src.SeqId > 0 {
|
||||
s += " seq=" + strconv.Itoa(src.SeqId)
|
||||
s += " seq=" + strconv.FormatInt(src.SeqId, 10)
|
||||
}
|
||||
if len(src.Payload) > 0 {
|
||||
s += " payload=<..." + strconv.Itoa(len(src.Payload)) + " bytes ...>"
|
||||
|
||||
Reference in New Issue
Block a user