process: one EventHub pulls the module's one durable consumer, handlers by subject pattern; the views reader registers on it instead of pulling (class fix of B7c finding 1; ADR 0635 §5; issue 1966)
Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
@@ -46,6 +46,11 @@ type ProcessReader struct {
|
||||
// views event, so a module that hears other events through the same consumer (a module has one) handles them there.
|
||||
// Nil says them in the log, acknowledged: the module hears views events alone.
|
||||
Other func(jetstream.Msg)
|
||||
// Hub is the module's one pull of its durable consumer (process.EventHub), when other parts of the module hear events
|
||||
// too: the reader registers its views events on it and does not pull; the host starts the hub once, after every part
|
||||
// registered. Nil: the reader pulls the durable itself and takes every message (Other the rest), for a module that
|
||||
// hears nothing else.
|
||||
Hub *process.EventHub
|
||||
|
||||
mu sync.Mutex
|
||||
pics map[string]*Picture // by bucket name <owner>_<state>
|
||||
@@ -528,14 +533,21 @@ func (e entry) Created() time.Time { return e.at }
|
||||
func (e entry) Delta() uint64 { return 0 }
|
||||
func (e entry) Operation() jetstream.KeyValueOp { return e.op }
|
||||
|
||||
// EventsPattern is the subjects of every owner's views events on the shared events stream.
|
||||
const EventsPattern = "mesh.mod.*.event." + EventPrefix + "*"
|
||||
|
||||
// Start hears the owners' views events on the process's durable consumer of the shared events stream (its manifest's
|
||||
// `consumes` `<owner>.views.<state>`), keeps each status in the process's state `first-views` and hears the hand asks the
|
||||
// tools bundle's `<reader>_first_view_again` writes there (StatusTools), then asks every first view (Ask). A consumer the
|
||||
// bus does not have yet is said: the picture is then the first view's alone, asked again on a gap or by hand.
|
||||
func (r *ProcessReader) Start(ctx context.Context, js jetstream.JetStream, cred process.Account, status *process.AwaitedBucket) {
|
||||
cons, err := cred.EventConsumer(ctx, js, process.EventsStream)
|
||||
if err == nil {
|
||||
_, err = process.HearEvents(cons, r.Hear(ctx), r.logf)
|
||||
hub, pattern, own := r.Hub, EventsPattern, false
|
||||
if hub == nil {
|
||||
hub, pattern, own = process.NewEventHub(r.logf), ">", true
|
||||
}
|
||||
err := hub.Handle(pattern, r.Hear(ctx))
|
||||
if err == nil && own {
|
||||
err = hub.Start(ctx, js, cred)
|
||||
}
|
||||
if err != nil {
|
||||
r.logf("the consumer %s on %s is not heard (%v): the states followed are the first views' alone, asked again by hand, until the %s starts again",
|
||||
|
||||
Reference in New Issue
Block a user