Files
mesh-catalog/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/settings.go
T
jschoubben 7cc4a33cc5 GATE A-24, §172, §431, §592, §593, §613: the gate keeps no merge states; deliveries, show, groups and stalled answer the delivery records
Removes holder, table, approval, ready, onestatus, pullkey, checks, group_merge, the effects, the forge reads, the teller's
and the view's reads, kvOperator, kvPulls, delivery_merge_again and their tests. deliveries, show, groups and stalled answer
the records as kept (stalled: a record open past a day, and an act owed unanswered past 15 minutes, read from the record's
acts); the switch reads the old section deliveries and says approval-carried for each unperformed merges key. The manifest
drops pulls, asks, reads, the forge, teller and view consumes and invokes, and the events group and merged.

Builds: design 47 G §172, §431, §592, §593, §613, A-24, A-35 (G-3, G-9, G-16, G-17, G-20)

Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
2026-11-11 22:10:42 +01:00

60 lines
1.7 KiB
Go

package main
// The gate's setting (design 47 *The delivery record*), merged by the mesh into one JSON file the env names. Each has a
// default here, so a gate started without the file, or with a value it cannot read, keeps the decided bound and says
// why once.
import (
"encoding/json"
"errors"
"fmt"
"os"
"time"
)
// Settings are the operator's values for this module.
type Settings struct {
// RecordRetentionDays is how many days a delivery record is kept from when it opened (design 47 *The delivery
// record*); nil keeps DefaultRecordRetention.
RecordRetentionDays *int `json:"record-retention"`
}
// readSettings reads the settings file; a value that is not a whole number of days, from 1 to 3650, is refused.
func readSettings(path string) (Settings, error) {
var s Settings
if path == "" {
return s, errors.New("started without a settings file")
}
raw, err := os.ReadFile(path)
if err != nil {
return s, err
}
var loose map[string]any
if err := json.Unmarshal(raw, &loose); err != nil {
return s, fmt.Errorf("the settings file is not JSON: %v", err)
}
switch v := loose["record-retention"].(type) {
case nil:
case float64:
n := int(v)
if v < 1 || v > 3650 || v != float64(n) {
return Settings{}, errors.New("record-retention is not a whole number of days, from 1 to 3650")
}
s.RecordRetentionDays = &n
default:
return Settings{}, errors.New("record-retention is not a number")
}
return s, nil
}
// recordRetention is how long a delivery record is kept from when it opened.
func (h *Holder) recordRetention() time.Duration {
if h.Settings == nil {
return DefaultRecordRetention
}
if n := h.Settings().RecordRetentionDays; n != nil {
return time.Duration(*n) * 24 * time.Hour
}
return DefaultRecordRetention
}