Area 5 (join 11): mesh-recovery's and restic's finding writers pass their finding-events binding
nats and distribution declare the old stream form and require no finding-events, so their writers stay on it. Builds: design 47 G A-274 (answers G-22) Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
@@ -86,9 +86,13 @@ func (l *liveBus) PutOffs() PutOffState { return stateOfPutOffs{l.conn.State(Put
|
||||
// Findings starts the module's held finding writer over its state `findings` (§561), as the recovery module does (§461): started
|
||||
// before the night's first backup, so what it writes is held and written. It answers how to close it.
|
||||
func (l *liveBus) Findings(ctx context.Context, logf func(string, ...any)) (Findings, func(), error) {
|
||||
// The module's finding stream is its `finding-events` entry, asked of the seat mesh-broker's show once (A-274, §529); the
|
||||
// night's process lives one night, so it hears no recreated of it. Until it answers, the writer holds its events.
|
||||
binding := process.NewBinding(BrokerSeat, l.account.Module, l.conn.CallKept, logf, views.FindingEventsLocal)
|
||||
binding.Ask(views.FindingEventsLocal)
|
||||
w, err := views.NewHeldWriter(views.WriterConfig[meshconditions.Finding, meshconditions.FindingCleared, meshconditions.FindingsStated, meshconditions.FindingsAskedEvent]{
|
||||
Asked: meshconditions.SubjectFindingsAsked, Module: l.account.Module, Node: l.account.Node, State: l.conn.State("findings"),
|
||||
Kinds: []string{FindingBackupWaits}, JS: l.js, Conn: l.nc, Logf: logf})
|
||||
Kinds: []string{FindingBackupWaits}, JS: l.js, Conn: l.nc, Bindings: binding, Logf: logf})
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
@@ -145,6 +145,7 @@ func TestTheNightSaysItsItemsAndGivesWayToARestoreOnTheBus(t *testing.T) {
|
||||
}
|
||||
}
|
||||
for _, s := range []jetstream.StreamConfig{{Name: "RESTIC_FINDINGS", Subjects: []string{"mesh.stream.restic.event.>"}},
|
||||
{Name: "RESTIC_FINDING_EVENTS", Subjects: []string{"mesh.bus.restic.finding-events.>"}},
|
||||
{Name: "FINDINGS_ASKED", Subjects: []string{meshconditions.SubjectFindingsAsked}}} {
|
||||
if _, err := js.CreateStream(ctx, s); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -158,6 +159,14 @@ func TestTheNightSaysItsItemsAndGivesWayToARestoreOnTheBus(t *testing.T) {
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// The seat mesh-broker's show names the module's `finding-events` entry (A-274).
|
||||
if _, err := nc.Subscribe("mesh.seat.mesh-broker.call.show.*", func(msg *nats.Msg) {
|
||||
body, _ := json.Marshal(map[string]any{"result": map[string]any{"binding": map[string]any{"local": "finding-events", "storage": "stream",
|
||||
"template": "events", "stream": "RESTIC_FINDING_EVENTS", "subject": "mesh.bus.restic.finding-events"}}, "node": "ace"})
|
||||
_ = msg.Respond(body)
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
findings, closeFindings, err := live.Findings(ctx, t.Logf)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -241,4 +250,14 @@ func TestTheNightSaysItsItemsAndGivesWayToARestoreOnTheBus(t *testing.T) {
|
||||
if err != nil || waits != 1 {
|
||||
t.Fatalf("the findings kept: %v, %v", ks, err)
|
||||
}
|
||||
// A-274: the finding events went under the finding-events binding, none on the old stream.
|
||||
for stream, want := range map[string]bool{"RESTIC_FINDING_EVENTS": true, "RESTIC_FINDINGS": false} {
|
||||
st, err := js.Stream(ctx, stream)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if info, err := st.Info(ctx); err != nil || (info.State.Msgs > 0) != want {
|
||||
t.Fatalf("%s holds %d finding events (%v), want some: %v", stream, info.State.Msgs, err, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user