discovery: +invoke url
This commit is contained in:
@@ -4,6 +4,7 @@ runtime:
|
||||
grpc:
|
||||
network: tcp
|
||||
address: ":50070"
|
||||
advertise_host: "sendico_chain_gateway"
|
||||
enable_reflection: true
|
||||
enable_health: true
|
||||
|
||||
|
||||
@@ -148,7 +148,12 @@ 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()
|
||||
}
|
||||
opts := []gatewayservice.Option{
|
||||
gatewayservice.WithDiscoveryInvokeURI(invokeURI),
|
||||
gatewayservice.WithNetworks(networkConfigs),
|
||||
gatewayservice.WithServiceWallet(walletConfig),
|
||||
gatewayservice.WithKeyManager(keyManager),
|
||||
|
||||
@@ -83,3 +83,10 @@ func WithSettings(settings CacheSettings) Option {
|
||||
s.settings = settings.withDefaults()
|
||||
}
|
||||
}
|
||||
|
||||
// WithDiscoveryInvokeURI sets the invoke URI used when announcing the gateway.
|
||||
func WithDiscoveryInvokeURI(invokeURI string) Option {
|
||||
return func(s *Service) {
|
||||
s.invokeURI = strings.TrimSpace(invokeURI)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ type Service struct {
|
||||
drivers *drivers.Registry
|
||||
commands commands.Registry
|
||||
announcers []*discovery.Announcer
|
||||
invokeURI string
|
||||
|
||||
connectorv1.UnimplementedConnectorServiceServer
|
||||
}
|
||||
@@ -209,7 +210,7 @@ func (s *Service) startDiscoveryAnnouncers() {
|
||||
Network: network.Name,
|
||||
Operations: []string{"balance.read", "payin.crypto", "payout.crypto", "fee.send"},
|
||||
Currencies: currencies,
|
||||
InvokeURI: discovery.DefaultInvokeURI(string(mservice.ChainGateway)),
|
||||
InvokeURI: s.invokeURI,
|
||||
Version: version,
|
||||
}
|
||||
announcer := discovery.NewAnnouncer(s.logger, s.producer, string(mservice.ChainGateway), announce)
|
||||
|
||||
@@ -4,6 +4,7 @@ runtime:
|
||||
grpc:
|
||||
network: tcp
|
||||
address: ":50075"
|
||||
advertise_host: "sendico_mntx_gateway"
|
||||
enable_reflection: true
|
||||
enable_health: true
|
||||
|
||||
|
||||
@@ -184,7 +184,12 @@ func (i *Imp) Start() error {
|
||||
)
|
||||
|
||||
serviceFactory := func(logger mlogger.Logger, _ struct{}, producer msg.Producer) (grpcapp.Service, error) {
|
||||
invokeURI := ""
|
||||
if cfg.GRPC != nil {
|
||||
invokeURI = cfg.GRPC.DiscoveryInvokeURI()
|
||||
}
|
||||
svc := mntxservice.NewService(logger,
|
||||
mntxservice.WithDiscoveryInvokeURI(invokeURI),
|
||||
mntxservice.WithProducer(producer),
|
||||
mntxservice.WithMonetixConfig(monetixCfg),
|
||||
mntxservice.WithGatewayDescriptor(gatewayDescriptor),
|
||||
|
||||
@@ -2,6 +2,7 @@ package gateway
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/tech/sendico/gateway/mntx/internal/service/monetix"
|
||||
"github.com/tech/sendico/pkg/clock"
|
||||
@@ -52,3 +53,10 @@ func WithGatewayDescriptor(descriptor *gatewayv1.GatewayInstanceDescriptor) Opti
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithDiscoveryInvokeURI sets the invoke URI used when announcing the gateway.
|
||||
func WithDiscoveryInvokeURI(invokeURI string) Option {
|
||||
return func(s *Service) {
|
||||
s.invokeURI = strings.TrimSpace(invokeURI)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ type Service struct {
|
||||
card *cardPayoutProcessor
|
||||
gatewayDescriptor *gatewayv1.GatewayInstanceDescriptor
|
||||
announcer *discovery.Announcer
|
||||
invokeURI string
|
||||
|
||||
connectorv1.UnimplementedConnectorServiceServer
|
||||
}
|
||||
@@ -145,7 +146,7 @@ func (s *Service) startDiscoveryAnnouncer() {
|
||||
Service: "CARD_PAYOUT_RAIL_GATEWAY",
|
||||
Rail: "CARD_PAYOUT",
|
||||
Operations: []string{"payout.card"},
|
||||
InvokeURI: discovery.DefaultInvokeURI(string(mservice.MntxGateway)),
|
||||
InvokeURI: s.invokeURI,
|
||||
Version: appversion.Create().Short(),
|
||||
}
|
||||
if s.gatewayDescriptor != nil {
|
||||
|
||||
@@ -4,6 +4,7 @@ runtime:
|
||||
grpc:
|
||||
network: tcp
|
||||
address: ":50080"
|
||||
advertise_host: "sendico_payment_gateway"
|
||||
enable_reflection: true
|
||||
enable_health: true
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user