H-A-196: a process pulls a durable consumer once
A second pull loop on a durable the same process already pulls takes every other event from the first, and nothing said so: the tool runner's two loops on the indexer bundle's durable left the catalog seat's revision verb stale twice today. The SDK now refuses it at bind time, naming the durable and both binders: PullOnce claims a durable (by stream, name and the time the bus made it), and HearEvents and Conn.Consume claim through it, releasing on stop, drain or the bus ending the loop. Builds: design 47 H H-A-196
This commit is contained in:
+12
-2
@@ -104,9 +104,19 @@ func (a Account) namedEventConsumerName(suffix string) string {
|
||||
}
|
||||
|
||||
// HearEvents pulls from cons, handing each message to handle, and says every error the bus reports while
|
||||
// hearing through logf ("hearing the bus: ..."). The caller stops the returned context.
|
||||
// hearing through logf ("hearing the bus: ..."). The caller stops the returned context. A durable this process pulls
|
||||
// already is refused (PullOnce, design 47 H, H-A-196).
|
||||
func HearEvents(cons jetstream.Consumer, handle func(jetstream.Msg), logf func(string, ...any)) (jetstream.ConsumeContext, error) {
|
||||
return cons.Consume(handle, jetstream.ConsumeErrHandler(func(_ jetstream.ConsumeContext, err error) {
|
||||
release, err := PullOnce(cons, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cc, err := cons.Consume(handle, jetstream.ConsumeErrHandler(func(_ jetstream.ConsumeContext, err error) {
|
||||
logf("hearing the bus: %v", err)
|
||||
}))
|
||||
if err != nil {
|
||||
release()
|
||||
return nil, err
|
||||
}
|
||||
return claimed(cc, release), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user