outbox for gateways

This commit is contained in:
Stephan D
2026-02-18 01:35:28 +01:00
parent 974caf286c
commit 69531cee73
221 changed files with 12172 additions and 782 deletions

View File

@@ -7,6 +7,7 @@ import (
"strings"
"time"
gatewayoutbox "github.com/tech/sendico/gateway/common/outbox"
"github.com/tech/sendico/gateway/tgsettle/storage"
storagemodel "github.com/tech/sendico/gateway/tgsettle/storage/model"
"github.com/tech/sendico/pkg/api/routers"
@@ -20,6 +21,7 @@ import (
tnotifications "github.com/tech/sendico/pkg/messaging/notifications/telegram"
"github.com/tech/sendico/pkg/mlogger"
"github.com/tech/sendico/pkg/model"
pmodel "github.com/tech/sendico/pkg/model"
"github.com/tech/sendico/pkg/mservice"
paymenttypes "github.com/tech/sendico/pkg/payments/types"
moneyv1 "github.com/tech/sendico/pkg/proto/common/money/v1"
@@ -48,12 +50,13 @@ const (
)
type Config struct {
Rail string
TargetChatIDEnv string
TimeoutSeconds int32
AcceptedUserIDs []string
SuccessReaction string
InvokeURI string
Rail string
TargetChatIDEnv string
TimeoutSeconds int32
AcceptedUserIDs []string
SuccessReaction string
InvokeURI string
MessagingSettings pmodel.SettingsT
}
type Service struct {
@@ -62,11 +65,13 @@ type Service struct {
producer msg.Producer
broker mb.Broker
cfg Config
msgCfg pmodel.SettingsT
rail string
chatID string
announcer *discovery.Announcer
invokeURI string
successReaction string
outbox gatewayoutbox.ReliableRuntime
consumers []msg.Consumer
@@ -84,6 +89,7 @@ func NewService(logger mlogger.Logger, repo storage.Repository, producer msg.Pro
producer: producer,
broker: broker,
cfg: cfg,
msgCfg: cfg.MessagingSettings,
rail: strings.TrimSpace(cfg.Rail),
invokeURI: strings.TrimSpace(cfg.InvokeURI),
}
@@ -92,6 +98,9 @@ func NewService(logger mlogger.Logger, repo storage.Repository, producer msg.Pro
if svc.successReaction == "" {
svc.successReaction = defaultTelegramSuccessReaction
}
if err := svc.startOutboxReliableProducer(); err != nil {
svc.logger.Warn("Failed to initialise outbox reliable producer", zap.Error(err))
}
svc.startConsumers()
svc.startAnnouncer()
return svc
@@ -107,6 +116,7 @@ func (s *Service) Shutdown() {
if s == nil {
return
}
s.outbox.Stop()
if s.announcer != nil {
s.announcer.Stop()
}