discovery: +invoke url
This commit is contained in:
@@ -4,6 +4,7 @@ runtime:
|
||||
grpc:
|
||||
network: tcp
|
||||
address: ":50051"
|
||||
advertise_host: "sendico_fx_oracle"
|
||||
enable_reflection: true
|
||||
enable_health: true
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ func (i *Imp) Start() error {
|
||||
}
|
||||
|
||||
serviceFactory := func(logger mlogger.Logger, repo storage.Repository, producer msg.Producer) (grpcapp.Service, error) {
|
||||
svc := oracle.NewService(logger, repo, producer)
|
||||
svc := oracle.NewService(logger, repo, producer, cfg.GRPC.DiscoveryInvokeURI())
|
||||
i.service = svc
|
||||
return svc, nil
|
||||
}
|
||||
|
||||
@@ -42,15 +42,17 @@ type Service struct {
|
||||
storage storage.Repository
|
||||
producer pmessaging.Producer
|
||||
announcer *discovery.Announcer
|
||||
invokeURI string
|
||||
oraclev1.UnimplementedOracleServer
|
||||
}
|
||||
|
||||
func NewService(logger mlogger.Logger, repo storage.Repository, prod pmessaging.Producer) *Service {
|
||||
func NewService(logger mlogger.Logger, repo storage.Repository, prod pmessaging.Producer, invokeURI string) *Service {
|
||||
initMetrics()
|
||||
svc := &Service{
|
||||
logger: logger.Named("oracle"),
|
||||
storage: repo,
|
||||
producer: prod,
|
||||
logger: logger.Named("oracle"),
|
||||
storage: repo,
|
||||
producer: prod,
|
||||
invokeURI: strings.TrimSpace(invokeURI),
|
||||
}
|
||||
svc.startDiscoveryAnnouncer()
|
||||
return svc
|
||||
@@ -78,6 +80,7 @@ func (s *Service) startDiscoveryAnnouncer() {
|
||||
announce := discovery.Announcement{
|
||||
Service: "FX_ORACLE",
|
||||
Operations: []string{"fx.quote"},
|
||||
InvokeURI: s.invokeURI,
|
||||
Version: appversion.Create().Short(),
|
||||
}
|
||||
s.announcer = discovery.NewAnnouncer(s.logger, s.producer, string(mservice.FXOracle), announce)
|
||||
|
||||
@@ -142,7 +142,7 @@ func TestServiceGetQuoteFirm(t *testing.T) {
|
||||
}
|
||||
repo.currencies = currencyStoreStub{}
|
||||
|
||||
svc := NewService(zap.NewNop(), repo, nil)
|
||||
svc := NewService(zap.NewNop(), repo, nil, "")
|
||||
|
||||
req := &oraclev1.GetQuoteRequest{
|
||||
Meta: &oraclev1.RequestMeta{
|
||||
@@ -189,7 +189,7 @@ func TestServiceGetQuoteRateNotFound(t *testing.T) {
|
||||
return nil, merrors.ErrNoData
|
||||
}},
|
||||
}
|
||||
svc := NewService(zap.NewNop(), repo, nil)
|
||||
svc := NewService(zap.NewNop(), repo, nil, "")
|
||||
|
||||
_, err := svc.GetQuote(context.Background(), &oraclev1.GetQuoteRequest{
|
||||
Pair: &fxv1.CurrencyPair{Base: "USD", Quote: "EUR"},
|
||||
@@ -263,7 +263,7 @@ func TestServiceGetQuoteCrossRate(t *testing.T) {
|
||||
repo.quotes = "esStoreStub{}
|
||||
repo.currencies = currencyStoreStub{}
|
||||
|
||||
svc := NewService(zap.NewNop(), repo, nil)
|
||||
svc := NewService(zap.NewNop(), repo, nil, "")
|
||||
|
||||
req := &oraclev1.GetQuoteRequest{
|
||||
Pair: &fxv1.CurrencyPair{Base: "EUR", Quote: "RUB"},
|
||||
@@ -352,7 +352,7 @@ func TestServiceLatestRateCross(t *testing.T) {
|
||||
repo.quotes = "esStoreStub{}
|
||||
repo.currencies = currencyStoreStub{}
|
||||
|
||||
svc := NewService(zap.NewNop(), repo, nil)
|
||||
svc := NewService(zap.NewNop(), repo, nil, "")
|
||||
|
||||
resp, err := svc.LatestRate(context.Background(), &oraclev1.LatestRateRequest{
|
||||
Pair: &fxv1.CurrencyPair{Base: "EUR", Quote: "RUB"},
|
||||
@@ -390,7 +390,7 @@ func TestServiceValidateQuote(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
svc := NewService(zap.NewNop(), repo, nil)
|
||||
svc := NewService(zap.NewNop(), repo, nil, "")
|
||||
|
||||
resp, err := svc.ValidateQuote(context.Background(), &oraclev1.ValidateQuoteRequest{QuoteRef: "q1"})
|
||||
if err != nil {
|
||||
@@ -409,7 +409,7 @@ func TestServiceConsumeQuoteExpired(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
svc := NewService(zap.NewNop(), repo, nil)
|
||||
svc := NewService(zap.NewNop(), repo, nil, "")
|
||||
|
||||
_, err := svc.ConsumeQuote(context.Background(), &oraclev1.ConsumeQuoteRequest{QuoteRef: "q1", LedgerTxnRef: "ledger"})
|
||||
if err == nil {
|
||||
@@ -439,7 +439,7 @@ func TestServiceLatestRateSuccess(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
svc := NewService(zap.NewNop(), repo, nil)
|
||||
svc := NewService(zap.NewNop(), repo, nil, "")
|
||||
|
||||
resp, err := svc.LatestRate(context.Background(), &oraclev1.LatestRateRequest{Pair: &fxv1.CurrencyPair{Base: "USD", Quote: "EUR"}})
|
||||
if err != nil {
|
||||
@@ -456,7 +456,7 @@ func TestServiceListPairs(t *testing.T) {
|
||||
return []*model.Pair{{Pair: model.CurrencyPair{Base: "USD", Quote: "EUR"}}}, nil
|
||||
}},
|
||||
}
|
||||
svc := NewService(zap.NewNop(), repo, nil)
|
||||
svc := NewService(zap.NewNop(), repo, nil, "")
|
||||
|
||||
resp, err := svc.ListPairs(context.Background(), &oraclev1.ListPairsRequest{})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user