Merge pull request 'added mntx client to payment orchestration' (#172) from mntx-170 into main
All checks were successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/mntx_gateway Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
All checks were successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/mntx_gateway Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
Reviewed-on: #172
This commit was merged in pull request #172.
This commit is contained in:
@@ -26,7 +26,7 @@ monetix:
|
|||||||
base_url_env: MONETIX_BASE_URL
|
base_url_env: MONETIX_BASE_URL
|
||||||
project_id_env: MONETIX_PROJECT_ID
|
project_id_env: MONETIX_PROJECT_ID
|
||||||
secret_key_env: MONETIX_SECRET_KEY
|
secret_key_env: MONETIX_SECRET_KEY
|
||||||
allowed_currencies: ["USD", "EUR"]
|
allowed_currencies: ["RUB"]
|
||||||
require_customer_address: false
|
require_customer_address: false
|
||||||
request_timeout_seconds: 15
|
request_timeout_seconds: 15
|
||||||
status_success: "success"
|
status_success: "success"
|
||||||
|
|||||||
@@ -51,6 +51,12 @@ gateway:
|
|||||||
call_timeout_seconds: 3
|
call_timeout_seconds: 3
|
||||||
insecure: true
|
insecure: true
|
||||||
|
|
||||||
|
mntx:
|
||||||
|
address: "sendico_mntx_gateway:50075"
|
||||||
|
dial_timeout_seconds: 5
|
||||||
|
call_timeout_seconds: 3
|
||||||
|
insecure: true
|
||||||
|
|
||||||
oracle:
|
oracle:
|
||||||
address: "sendico_fx_oracle:50051"
|
address: "sendico_fx_oracle:50051"
|
||||||
dial_timeout_seconds: 5
|
dial_timeout_seconds: 5
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
oracleclient "github.com/tech/sendico/fx/oracle/client"
|
oracleclient "github.com/tech/sendico/fx/oracle/client"
|
||||||
chainclient "github.com/tech/sendico/gateway/chain/client"
|
chainclient "github.com/tech/sendico/gateway/chain/client"
|
||||||
|
mntxclient "github.com/tech/sendico/gateway/mntx/client"
|
||||||
ledgerclient "github.com/tech/sendico/ledger/client"
|
ledgerclient "github.com/tech/sendico/ledger/client"
|
||||||
"github.com/tech/sendico/payments/orchestrator/internal/service/orchestrator"
|
"github.com/tech/sendico/payments/orchestrator/internal/service/orchestrator"
|
||||||
"github.com/tech/sendico/payments/orchestrator/storage"
|
"github.com/tech/sendico/payments/orchestrator/storage"
|
||||||
@@ -36,6 +37,7 @@ type Imp struct {
|
|||||||
feesConn *grpc.ClientConn
|
feesConn *grpc.ClientConn
|
||||||
ledgerClient ledgerclient.Client
|
ledgerClient ledgerclient.Client
|
||||||
gatewayClient chainclient.Client
|
gatewayClient chainclient.Client
|
||||||
|
mntxClient mntxclient.Client
|
||||||
oracleClient oracleclient.Client
|
oracleClient oracleclient.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,6 +46,7 @@ type config struct {
|
|||||||
Fees clientConfig `yaml:"fees"`
|
Fees clientConfig `yaml:"fees"`
|
||||||
Ledger clientConfig `yaml:"ledger"`
|
Ledger clientConfig `yaml:"ledger"`
|
||||||
Gateway clientConfig `yaml:"gateway"`
|
Gateway clientConfig `yaml:"gateway"`
|
||||||
|
Mntx clientConfig `yaml:"mntx"`
|
||||||
Oracle clientConfig `yaml:"oracle"`
|
Oracle clientConfig `yaml:"oracle"`
|
||||||
CardGateways map[string]cardGatewayRouteConfig `yaml:"card_gateways"`
|
CardGateways map[string]cardGatewayRouteConfig `yaml:"card_gateways"`
|
||||||
FeeAccounts map[string]string `yaml:"fee_ledger_accounts"`
|
FeeAccounts map[string]string `yaml:"fee_ledger_accounts"`
|
||||||
@@ -105,6 +108,9 @@ func (i *Imp) Shutdown() {
|
|||||||
if i.gatewayClient != nil {
|
if i.gatewayClient != nil {
|
||||||
_ = i.gatewayClient.Close()
|
_ = i.gatewayClient.Close()
|
||||||
}
|
}
|
||||||
|
if i.mntxClient != nil {
|
||||||
|
_ = i.mntxClient.Close()
|
||||||
|
}
|
||||||
if i.oracleClient != nil {
|
if i.oracleClient != nil {
|
||||||
_ = i.oracleClient.Close()
|
_ = i.oracleClient.Close()
|
||||||
}
|
}
|
||||||
@@ -139,6 +145,11 @@ func (i *Imp) Start() error {
|
|||||||
i.gatewayClient = gatewayClient
|
i.gatewayClient = gatewayClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mntxClient := i.initMntxClient(cfg.Mntx)
|
||||||
|
if mntxClient != nil {
|
||||||
|
i.mntxClient = mntxClient
|
||||||
|
}
|
||||||
|
|
||||||
oracleClient := i.initOracleClient(cfg.Oracle)
|
oracleClient := i.initOracleClient(cfg.Oracle)
|
||||||
if oracleClient != nil {
|
if oracleClient != nil {
|
||||||
i.oracleClient = oracleClient
|
i.oracleClient = oracleClient
|
||||||
@@ -155,6 +166,9 @@ func (i *Imp) Start() error {
|
|||||||
if gatewayClient != nil {
|
if gatewayClient != nil {
|
||||||
opts = append(opts, orchestrator.WithChainGatewayClient(gatewayClient))
|
opts = append(opts, orchestrator.WithChainGatewayClient(gatewayClient))
|
||||||
}
|
}
|
||||||
|
if mntxClient != nil {
|
||||||
|
opts = append(opts, orchestrator.WithMntxGateway(mntxClient))
|
||||||
|
}
|
||||||
if oracleClient != nil {
|
if oracleClient != nil {
|
||||||
opts = append(opts, orchestrator.WithOracleClient(oracleClient))
|
opts = append(opts, orchestrator.WithOracleClient(oracleClient))
|
||||||
}
|
}
|
||||||
@@ -192,11 +206,11 @@ func (i *Imp) initFeesClient(cfg clientConfig) (feesv1.FeeEngineClient, *grpc.Cl
|
|||||||
|
|
||||||
conn, err := grpc.DialContext(dialCtx, addr, grpc.WithTransportCredentials(creds))
|
conn, err := grpc.DialContext(dialCtx, addr, grpc.WithTransportCredentials(creds))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
i.logger.Warn("failed to connect to fees service", zap.String("address", addr), zap.Error(err))
|
i.logger.Warn("Failed to connect to fees service", zap.String("address", addr), zap.Error(err))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
i.logger.Info("connected to fees service", zap.String("address", addr))
|
i.logger.Info("Connected to fees service", zap.String("address", addr))
|
||||||
return feesv1.NewFeeEngineClient(conn), conn
|
return feesv1.NewFeeEngineClient(conn), conn
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,10 +230,10 @@ func (i *Imp) initLedgerClient(cfg clientConfig) ledgerclient.Client {
|
|||||||
Insecure: cfg.InsecureTransport,
|
Insecure: cfg.InsecureTransport,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
i.logger.Warn("failed to connect to ledger service", zap.String("address", addr), zap.Error(err))
|
i.logger.Warn("Failed to connect to ledger service", zap.String("address", addr), zap.Error(err))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
i.logger.Info("connected to ledger service", zap.String("address", addr))
|
i.logger.Info("Connected to ledger service", zap.String("address", addr))
|
||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,6 +260,28 @@ func (i *Imp) initGatewayClient(cfg clientConfig) chainclient.Client {
|
|||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (i *Imp) initMntxClient(cfg clientConfig) mntxclient.Client {
|
||||||
|
addr := cfg.address()
|
||||||
|
if addr == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), cfg.dialTimeout())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
client, err := mntxclient.New(ctx, mntxclient.Config{
|
||||||
|
Address: addr,
|
||||||
|
DialTimeout: cfg.dialTimeout(),
|
||||||
|
CallTimeout: cfg.callTimeout(),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
i.logger.Warn("Failed to connect to mntx gateway service", zap.String("address", addr), zap.Error(err))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
i.logger.Info("Connected to mntx gateway service", zap.String("address", addr))
|
||||||
|
return client
|
||||||
|
}
|
||||||
|
|
||||||
func (i *Imp) initOracleClient(cfg clientConfig) oracleclient.Client {
|
func (i *Imp) initOracleClient(cfg clientConfig) oracleclient.Client {
|
||||||
addr := cfg.address()
|
addr := cfg.address()
|
||||||
if addr == "" {
|
if addr == "" {
|
||||||
@@ -262,10 +298,10 @@ func (i *Imp) initOracleClient(cfg clientConfig) oracleclient.Client {
|
|||||||
Insecure: cfg.InsecureTransport,
|
Insecure: cfg.InsecureTransport,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
i.logger.Warn("failed to connect to oracle service", zap.String("address", addr), zap.Error(err))
|
i.logger.Warn("Failed to connect to oracle service", zap.String("address", addr), zap.Error(err))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
i.logger.Info("connected to oracle service", zap.String("address", addr))
|
i.logger.Info("Connected to oracle service", zap.String("address", addr))
|
||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user