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

@@ -3,6 +3,7 @@ package gateway
import (
"context"
gatewayoutbox "github.com/tech/sendico/gateway/common/outbox"
"github.com/tech/sendico/gateway/tron/internal/appversion"
"github.com/tech/sendico/gateway/tron/internal/keymanager"
"github.com/tech/sendico/gateway/tron/internal/service/gateway/commands"
@@ -19,9 +20,11 @@ import (
"github.com/tech/sendico/pkg/discovery"
msg "github.com/tech/sendico/pkg/messaging"
"github.com/tech/sendico/pkg/mlogger"
pmodel "github.com/tech/sendico/pkg/model"
"github.com/tech/sendico/pkg/mservice"
connectorv1 "github.com/tech/sendico/pkg/proto/connector/v1"
chainv1 "github.com/tech/sendico/pkg/proto/gateway/chain/v1"
"go.uber.org/zap"
"google.golang.org/grpc"
)
@@ -40,9 +43,11 @@ type Service struct {
logger mlogger.Logger
storage storage.Repository
producer msg.Producer
msgCfg pmodel.SettingsT
clock clockpkg.Clock
settings CacheSettings
outbox gatewayoutbox.ReliableRuntime
networks map[string]shared.Network
serviceWallet shared.ServiceWallet
@@ -64,6 +69,7 @@ func NewService(logger mlogger.Logger, repo storage.Repository, producer msg.Pro
logger: logger.Named("service"),
storage: repo,
producer: producer,
msgCfg: map[string]any{},
clock: clockpkg.System{},
settings: defaultSettings(),
networks: map[string]shared.Network{},
@@ -85,6 +91,9 @@ func NewService(logger mlogger.Logger, repo storage.Repository, producer msg.Pro
}
svc.settings = svc.settings.withDefaults()
svc.networkRegistry = rpcclient.NewRegistry(svc.networks, svc.rpcClients)
if err := svc.startOutboxReliableProducer(); err != nil {
svc.logger.Warn("Failed to initialise outbox reliable producer", zap.Error(err))
}
svc.commands = commands.NewRegistry(commands.RegistryDeps{
Wallet: commandsWalletDeps(svc),
@@ -106,6 +115,7 @@ func (s *Service) Shutdown() {
if s == nil {
return
}
s.outbox.Stop()
for _, announcer := range s.announcers {
if announcer != nil {
announcer.Stop()