discovery: +invoke url

This commit is contained in:
Stephan D
2026-01-19 11:07:21 +01:00
parent 1eb5a918a0
commit 64803a21e0
26 changed files with 170 additions and 32 deletions

View File

@@ -4,6 +4,7 @@ runtime:
grpc:
network: tcp
address: ":50080"
advertise_host: "sendico_payment_gateway"
enable_reflection: true
enable_health: true

View File

@@ -85,11 +85,16 @@ func (i *Imp) Start() error {
}
serviceFactory := func(logger mlogger.Logger, repo storage.Repository, producer msg.Producer) (grpcapp.Service, error) {
invokeURI := ""
if cfg.GRPC != nil {
invokeURI = cfg.GRPC.DiscoveryInvokeURI()
}
gwCfg := gateway.Config{
Rail: cfg.Gateway.Rail,
TargetChatIDEnv: cfg.Gateway.TargetChatIDEnv,
TimeoutSeconds: cfg.Gateway.TimeoutSeconds,
AcceptedUserIDs: cfg.Gateway.AcceptedUserIDs,
InvokeURI: invokeURI,
}
svc := gateway.NewService(logger, repo, producer, broker, gwCfg)
i.service = svc

View File

@@ -50,6 +50,7 @@ type Config struct {
TargetChatIDEnv string
TimeoutSeconds int32
AcceptedUserIDs []string
InvokeURI string
}
type Service struct {
@@ -61,6 +62,7 @@ type Service struct {
rail string
chatID string
announcer *discovery.Announcer
invokeURI string
mu sync.Mutex
pending map[string]*model.PaymentGatewayIntent
@@ -81,6 +83,7 @@ func NewService(logger mlogger.Logger, repo storage.Repository, producer msg.Pro
broker: broker,
cfg: cfg,
rail: strings.TrimSpace(cfg.Rail),
invokeURI: strings.TrimSpace(cfg.InvokeURI),
pending: map[string]*model.PaymentGatewayIntent{},
}
svc.chatID = strings.TrimSpace(readEnv(cfg.TargetChatIDEnv))
@@ -411,7 +414,7 @@ func (s *Service) startAnnouncer() {
Service: string(mservice.PaymentGateway),
Rail: s.rail,
Operations: caps,
InvokeURI: discovery.DefaultInvokeURI(string(mservice.PaymentGateway)),
InvokeURI: s.invokeURI,
}
s.announcer = discovery.NewAnnouncer(s.logger, s.producer, string(mservice.PaymentGateway), announce)
s.announcer.Start()