Compare commits
2
Commits
go/v0.1.26
...
go/v0.1.27
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc138366af | ||
|
|
4a5eb26f4e |
@@ -154,7 +154,9 @@ func subTheViewsReaderAndTwoHandlersShareTheModulesOneDurable(t *testing.T) {
|
||||
hub := process.NewEventHub(t.Logf)
|
||||
got := map[string]chan string{"a": make(chan string, 8), "b": make(chan string, 8)}
|
||||
for name, pattern := range map[string]string{"a": "mesh.mod.p.event.a", "b": "mesh.mod.q.event.b.*"} {
|
||||
if err := hub.Handle(pattern, func(m jetstream.Msg) { _ = m.Ack(); got[name] <- m.Subject() }); err != nil {
|
||||
// The handlers' acknowledgement waits for the bus's answer, so a message a handler handed on is acknowledged
|
||||
// on the bus, and every one the hub handed before it too (acks of one consumer are taken in order).
|
||||
if err := hub.Handle(pattern, func(m jetstream.Msg) { _ = m.DoubleAck(ctx); got[name] <- m.Subject() }); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -230,12 +232,25 @@ func subTheViewsReaderAndTwoHandlersShareTheModulesOneDurable(t *testing.T) {
|
||||
if len(got["a"])+len(got["b"])+len(seatHeard) != 0 {
|
||||
t.Fatal("a handler heard a message that was another's, or one twice")
|
||||
}
|
||||
// The reader acknowledges an event after it took it into its picture and the adopted handler returned, so the
|
||||
// picture and the handler say nothing of its ack: one more event, handed after them in order and acknowledged with
|
||||
// the bus's answer, is the mark that every ack before it has landed (the build node, main.54, read one pending). An
|
||||
// event said after the mark (the owner's own mark of its burst) may still wait for its ack, so the floor is read.
|
||||
mark, err := js.Publish(ctx, "mesh.mod.p.event.a", []byte(`"the mark"`))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
select {
|
||||
case <-got["a"]:
|
||||
case <-time.After(10 * time.Second):
|
||||
t.Fatal("the mark after the handled events was not heard")
|
||||
}
|
||||
cons, err := js.Consumer(ctx, process.EventsStream, cred.EventConsumerName())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if info, err := cons.Info(ctx); err != nil || info.NumAckPending != 0 {
|
||||
t.Fatalf("a message was left unacknowledged: %+v %v", info, err)
|
||||
if info, err := cons.Info(ctx); err != nil || info.AckFloor.Stream < mark.Sequence {
|
||||
t.Fatalf("a message up to the mark %d was left unacknowledged: %+v %v", mark.Sequence, info, err)
|
||||
}
|
||||
// H-A-169: the one event no handler takes is the module's finding event-unhandled, counted once, naming its subject,
|
||||
// though the reader started twice.
|
||||
|
||||
Reference in New Issue
Block a user