A-283: the bus module's keeper makes a state bucket with the max-mib its requirement declares

Builds: design 47 G A-283 (G-22 lead answers, with A-277 and ADR 0595)

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
2026-11-12 13:13:05 +01:00
parent 0e9fb2cbe3
commit 0f796e6505
2 changed files with 11 additions and 1 deletions
@@ -341,6 +341,9 @@ func TestEachTemplateIsPlannedUnderTheModulesNames(t *testing.T) {
{name: "state", entry: entry("drafts", catalogue.StorageKeyValue, catalogue.TemplateState, map[string]string{"history": "5"}),
objects: "key-value mesh-knowledge_drafts {64 MiB, age 0, history 5, new, size 262144}; object-store mesh-knowledge_drafts-objects {16 MiB, age 0, history 0, new, size 0}",
binding: "bucket mesh-knowledge_drafts"},
{name: "state naming max-mib (A-283)", entry: entry("drafts", catalogue.StorageKeyValue, catalogue.TemplateState, map[string]string{"max-mib": "8"}),
objects: "key-value mesh-knowledge_drafts {8 MiB, age 0, history 1, new, size 262144}; object-store mesh-knowledge_drafts-objects {16 MiB, age 0, history 0, new, size 0}",
binding: "bucket mesh-knowledge_drafts"},
{name: "state naming objects-max-mib (§591)", entry: entry("drafts", catalogue.StorageKeyValue, catalogue.TemplateState, map[string]string{"objects-max-mib": "512"}),
objects: "key-value mesh-knowledge_drafts {64 MiB, age 0, history 1, new, size 262144}; object-store mesh-knowledge_drafts-objects {512 MiB, age 0, history 0, new, size 0}",
binding: "bucket mesh-knowledge_drafts"},
+8 -1
View File
@@ -315,7 +315,14 @@ func stateSettings(o options) (Settings, error) {
}
return Settings{}, fmt.Errorf("the option %s (one bucket per machine) is not made by the bus module yet: the module keeps one bucket", catalogue.OptionPerMachine)
}
return Settings{MaxBytes: StateCap, MaxAgeSeconds: ttl, History: history, Discard: DiscardNew, MaxMsgSize: ValueMost, KeyTTL: keyTTL}, nil
capMiB, err := o.int(catalogue.OptionCapMiB, StateCap/MiB)
if err != nil {
return Settings{}, err
}
if capMiB <= 0 {
return Settings{}, fmt.Errorf("the option %s of a state is %d, not a size above 0", catalogue.OptionCapMiB, capMiB)
}
return Settings{MaxBytes: capMiB * MiB, MaxAgeSeconds: ttl, History: history, Discard: DiscardNew, MaxMsgSize: ValueMost, KeyTTL: keyTTL}, nil
}
func logSettings(o options) (Settings, error) {