perf: expand gateway capacity and prevent receipt replay

This commit is contained in:
hectorzhao
2026-08-25 16:08:30 +08:00
parent 761c123b65
commit 9292352be1
48 changed files with 2001 additions and 144 deletions
+12 -16
View File
@@ -1,6 +1,7 @@
package upstream
import (
"cmpp-platform/gateway/internal/protocollog"
"context"
"fmt"
cmpp "github.com/bigwhite/gocmpp"
@@ -8,22 +9,7 @@ import (
"strings"
)
type protocolLogEvent struct {
Protocol string `json:"protocol"`
Direction string `json:"direction"`
EventType string `json:"eventType"`
Status string `json:"status"`
TenantID string `json:"tenantId,omitempty"`
ApplicationID string `json:"applicationId,omitempty"`
ChannelID string `json:"channelId,omitempty"`
Account string `json:"account,omitempty"`
MessageID string `json:"messageId,omitempty"`
GatewayMessageID string `json:"gatewayMessageId,omitempty"`
Phone string `json:"phone,omitempty"`
ResultCode string `json:"resultCode,omitempty"`
PayloadBytes int `json:"payloadBytes,omitempty"`
Detail map[string]any `json:"detail,omitempty"`
}
type protocolLogEvent = protocollog.Event
func (c *connection) emitDeliverResponse(pkt deliverPacket, responseErr error) {
status := "success"
@@ -71,6 +57,16 @@ func (c *connection) emitDeliverResponse(pkt deliverPacket, responseErr error) {
}
func (c *connection) emitProtocolLog(event protocolLogEvent) {
event.ConnectionID = c.identity()
event.GatewayInstanceID = c.gatewayInstanceID
if c.protocolLogPublisher != nil {
go func() {
if err := c.protocolLogPublisher.Publish(context.Background(), event); err != nil {
log.Printf("protocol log Redis publish failed channel_id=%s message_id=%s error=%q", event.ChannelID, event.MessageID, err)
}
}()
return
}
go func() {
ctx, cancel := context.WithTimeout(context.Background(), defaultHTTPTimeout)
defer cancel()