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

@@ -129,6 +129,11 @@ func (i *Imp) Start() error {
if oracleClient != nil {
opts = append(opts, fees.WithOracleClient(oracleClient))
}
if cfg.GRPC != nil {
if invokeURI := cfg.GRPC.DiscoveryInvokeURI(); invokeURI != "" {
opts = append(opts, fees.WithDiscoveryInvokeURI(invokeURI))
}
}
svc := fees.NewService(logger, repo, producer, opts...)
i.service = svc
return svc, nil

View File

@@ -1,6 +1,8 @@
package fees
import (
"strings"
internalcalculator "github.com/tech/sendico/billing/fees/internal/service/fees/internal/calculator"
oracleclient "github.com/tech/sendico/fx/oracle/client"
clockpkg "github.com/tech/sendico/pkg/clock"
@@ -46,3 +48,10 @@ func WithFeeResolver(r FeeResolver) Option {
}
}
}
// WithDiscoveryInvokeURI sets the invoke URI used when announcing the service in discovery.
func WithDiscoveryInvokeURI(invokeURI string) Option {
return func(s *Service) {
s.invokeURI = strings.TrimSpace(invokeURI)
}
}

View File

@@ -40,6 +40,7 @@ type Service struct {
oracle oracleclient.Client
resolver FeeResolver
announcer *discovery.Announcer
invokeURI string
feesv1.UnimplementedFeeEngineServer
}
@@ -93,6 +94,7 @@ func (s *Service) startDiscoveryAnnouncer() {
announce := discovery.Announcement{
Service: "BILLING_FEES",
Operations: []string{"fee.calc"},
InvokeURI: s.invokeURI,
Version: appversion.Create().Short(),
}
s.announcer = discovery.NewAnnouncer(s.logger, s.producer, string(mservice.FeePlans), announce)