networkmanager: the watcher names no node; the bundle fills in its own
The node-engine gives the watcher's process no MESH_NODE, so the watcher refused to start and crash-looped on g14. It needs none: a kept change holds its event, its sequence and its body, and the bundle fills its own node into the subject, the message id <node>.<event>.<sequence> and the body when it publishes, the same at every publish. Builds: design 08 sign-in-page §11, §12, §20; lead answer L-3 (hq 09c9a3e3)
This commit is contained in:
@@ -53,13 +53,20 @@ type Folder struct {
|
||||
Node string
|
||||
}
|
||||
|
||||
// theFolder is the account's folder, on the node the node-engine names (MESH_NODE).
|
||||
// theFolder is the account's folder, on the node the tool runner names the bundle (MESH_NODE).
|
||||
func theFolder() (Folder, error) {
|
||||
f, err := accountFolder()
|
||||
f.Node = os.Getenv("MESH_NODE")
|
||||
return f, err
|
||||
}
|
||||
|
||||
// accountFolder is the account's folder with no node: the watcher's, which names none (L-3).
|
||||
func accountFolder() (Folder, error) {
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return Folder{}, err
|
||||
}
|
||||
return Folder{Dir: filepath.Join(home, stateHome), Node: os.Getenv("MESH_NODE")}, nil
|
||||
return Folder{Dir: filepath.Join(home, stateHome)}, nil
|
||||
}
|
||||
|
||||
func (f Folder) path(name string) string { return filepath.Join(f.Dir, name) }
|
||||
@@ -108,18 +115,22 @@ func (f Folder) nextSequence() (uint64, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// Kept is one event the watcher kept for the bundle to publish: the seat's subject, the bus's message id and the body.
|
||||
// Kept is one change the watcher kept for the bundle to publish: the event's name, its sequence and its body, all
|
||||
// without the node. The watcher names no node; the bundle fills its own into the subject, the message id and the body's
|
||||
// node when it publishes (lead answer L-3).
|
||||
type Kept struct {
|
||||
Sequence uint64 `json:"-"`
|
||||
Subject string `json:"subject"`
|
||||
MessageID string `json:"message_id"`
|
||||
Body json.RawMessage `json:"body"`
|
||||
Sequence uint64 `json:"sequence"`
|
||||
Event string `json:"event"`
|
||||
Body json.RawMessage `json:"body"`
|
||||
}
|
||||
|
||||
// Name is the kept change as the journal names it: `<event>.<sequence>`.
|
||||
func (k Kept) Name() string { return fmt.Sprintf("%s.%d", k.Event, k.Sequence) }
|
||||
|
||||
func pendingFile(seq uint64) string { return fmt.Sprintf("%010d.json", seq) }
|
||||
|
||||
// keep writes one event into pending/: its message id `<node>.<event>.<sequence>`, made once (§20).
|
||||
func (f Folder) keep(event, subject string, body any) (Kept, error) {
|
||||
// keep writes one change into pending/ under the next sequence, made once (§20; L-3).
|
||||
func (f Folder) keep(event string, body any) (Kept, error) {
|
||||
raw, err := json.Marshal(body)
|
||||
if err != nil {
|
||||
return Kept{}, err
|
||||
@@ -131,7 +142,7 @@ func (f Folder) keep(event, subject string, body any) (Kept, error) {
|
||||
if err != nil {
|
||||
return Kept{}, err
|
||||
}
|
||||
k := Kept{Sequence: seq, Subject: subject, MessageID: fmt.Sprintf("%s.%s.%d", f.Node, event, seq), Body: raw}
|
||||
k := Kept{Sequence: seq, Event: event, Body: raw}
|
||||
data, err := json.Marshal(k)
|
||||
if err != nil {
|
||||
return Kept{}, err
|
||||
|
||||
Reference in New Issue
Block a user