Fix missing context in nats test, rehabilitate cmd
This commit is contained in:
parent
aa41a606dc
commit
839ffdabac
@ -43,8 +43,9 @@ func main() {
|
|||||||
|
|
||||||
menuStorageService := storage.NewMenuStorageService(connData, "")
|
menuStorageService := storage.NewMenuStorageService(connData, "")
|
||||||
|
|
||||||
eh := viseevent.NewEventsHandler(lookup.Api)
|
eu := viseevent.NewEventsUpdater(lookup.Api, menuStorageService)
|
||||||
n := nats.NewNatsSubscription(menuStorageService, eh)
|
eh := eu.ToEventsHandler()
|
||||||
|
n := nats.NewNatsSubscription(eh)
|
||||||
err = n.Connect(ctx, config.JetstreamURL)
|
err = n.Connect(ctx, config.JetstreamURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Stream connect err: %v", err)
|
fmt.Fprintf(os.Stderr, "Stream connect err: %v", err)
|
||||||
|
@ -46,6 +46,8 @@ func NewNatsSubscription(handler *apievent.EventsHandler) *NatsSubscription {
|
|||||||
func(n *NatsSubscription) Connect(ctx context.Context, connStr string) error {
|
func(n *NatsSubscription) Connect(ctx context.Context, connStr string) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
// enables set ctx in test, even if the connstr is invalid (js msg handler doesnt take context)
|
||||||
|
n.ctx = ctx
|
||||||
n.conn, err = nats.Connect(connStr)
|
n.conn, err = nats.Connect(connStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -67,7 +69,6 @@ func(n *NatsSubscription) Connect(ctx context.Context, connStr string) error {
|
|||||||
|
|
||||||
serverInfo := toServerInfo(n.conn)
|
serverInfo := toServerInfo(n.conn)
|
||||||
logg.DebugCtxf(ctx, "nats connected, starting consumer", "status", n.conn.Status(), "server", serverInfo)
|
logg.DebugCtxf(ctx, "nats connected, starting consumer", "status", n.conn.Status(), "server", serverInfo)
|
||||||
n.ctx = ctx
|
|
||||||
n.cctx, err = n.cs.Consume(n.handleEvent)
|
n.cctx, err = n.cs.Consume(n.handleEvent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -145,6 +145,7 @@ func TestHandleMsg(t *testing.T) {
|
|||||||
|
|
||||||
eh := eu.ToEventsHandler()
|
eh := eu.ToEventsHandler()
|
||||||
sub := NewNatsSubscription(eh)
|
sub := NewNatsSubscription(eh)
|
||||||
|
_ = sub.Connect(ctx, "")
|
||||||
|
|
||||||
data := fmt.Sprintf(`{
|
data := fmt.Sprintf(`{
|
||||||
"block": %d,
|
"block": %d,
|
||||||
|
@ -34,11 +34,11 @@ func(r *Router) Route(ctx context.Context, gev *geEvent.Event) error {
|
|||||||
logg.DebugCtxf(ctx, "have event", "ev", gev)
|
logg.DebugCtxf(ctx, "have event", "ev", gev)
|
||||||
evCC, ok := asCustodialRegistrationEvent(gev)
|
evCC, ok := asCustodialRegistrationEvent(gev)
|
||||||
if ok {
|
if ok {
|
||||||
return r.handler.Handle(ctx, apievent.EventTokenTransferTag, evCC)
|
return r.handler.Handle(ctx, apievent.EventRegistrationTag, evCC)
|
||||||
}
|
}
|
||||||
evTT, ok := asTokenTransferEvent(gev)
|
evTT, ok := asTokenTransferEvent(gev)
|
||||||
if ok {
|
if ok {
|
||||||
return r.handler.Handle(ctx, apievent.EventRegistrationTag, evTT)
|
return r.handler.Handle(ctx, apievent.EventTokenTransferTag, evTT)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Errorf("unexpected message")
|
return fmt.Errorf("unexpected message")
|
||||||
|
2
go.mod
2
go.mod
@ -6,7 +6,7 @@ require (
|
|||||||
git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d
|
git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d
|
||||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05
|
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250113213645-7c697394b5e7
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250113213645-7c697394b5e7
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-vise v0.0.0-20250113213915-63eb803022af
|
git.grassecon.net/grassrootseconomics/sarafu-vise v0.0.0-20250113220020-f67edfb5411d
|
||||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250113213325-5228aef0889b
|
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250113213325-5228aef0889b
|
||||||
github.com/grassrootseconomics/eth-tracker v1.3.0-rc
|
github.com/grassrootseconomics/eth-tracker v1.3.0-rc
|
||||||
github.com/grassrootseconomics/ussd-data-service v1.2.0-beta
|
github.com/grassrootseconomics/ussd-data-service v1.2.0-beta
|
||||||
|
4
go.sum
4
go.sum
@ -4,8 +4,8 @@ git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05
|
|||||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250113213645-7c697394b5e7 h1:P+Bi5jcQbnCrLnKNC5k8XDTBsocyZTVifqDyZY6d0w8=
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250113213645-7c697394b5e7 h1:P+Bi5jcQbnCrLnKNC5k8XDTBsocyZTVifqDyZY6d0w8=
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250113213645-7c697394b5e7/go.mod h1:X9aQF93xw3vcW2QftJfzLewvbotRM0U00DRtdmFw294=
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250113213645-7c697394b5e7/go.mod h1:X9aQF93xw3vcW2QftJfzLewvbotRM0U00DRtdmFw294=
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-vise v0.0.0-20250113213915-63eb803022af h1:iwJ4iiF3Wbmkob++qCfj67URtdV2i6pdb9IkvmnBvQw=
|
git.grassecon.net/grassrootseconomics/sarafu-vise v0.0.0-20250113220020-f67edfb5411d h1:4nj54h7Fb/Rok6afR3wbMZPeNKKXr/1j0eYYSj/T2wk=
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-vise v0.0.0-20250113213915-63eb803022af/go.mod h1:1WryKcUnFI1J4Jl3wZJ4DX/7lnew+0PDY8xWvqc46UI=
|
git.grassecon.net/grassrootseconomics/sarafu-vise v0.0.0-20250113220020-f67edfb5411d/go.mod h1:1WryKcUnFI1J4Jl3wZJ4DX/7lnew+0PDY8xWvqc46UI=
|
||||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250113213325-5228aef0889b h1:6SieNUSEKbkjzquuwazs/lVG56zdEWF10zQQEMRJfMs=
|
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250113213325-5228aef0889b h1:6SieNUSEKbkjzquuwazs/lVG56zdEWF10zQQEMRJfMs=
|
||||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250113213325-5228aef0889b/go.mod h1:E6W7ZOa7ZvVr0Bc5ot0LNSwpSPYq4hXlAIvEPy3AJ7U=
|
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250113213325-5228aef0889b/go.mod h1:E6W7ZOa7ZvVr0Bc5ot0LNSwpSPYq4hXlAIvEPy3AJ7U=
|
||||||
github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=
|
github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=
|
||||||
|
Loading…
Reference in New Issue
Block a user