carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package moves
2
3// The staging layout (§7.3): one prefix per operation in the target
4// bucket, one subprefix per artifact class, so MirrorPrefix on replica/
5// can never delete an archive, a snapshot or move.json.
6func StagingPrefix(host, opID string) string { return "moves/" + host + "/" + opID + "/" }
7func ReplicaPrefix(host, opID string) string { return StagingPrefix(host, opID) + "replica/" }
8func FilesPrefix(host, opID string) string { return StagingPrefix(host, opID) + "files/" }
9func TimersPrefix(host, opID string) string { return StagingPrefix(host, opID) + "timers/" }
10func MoveJSONKey(host, opID string) string { return StagingPrefix(host, opID) + "move.json" }
11
12// BuildStateKey is the lane's copy of the instance's build-state.json
13// (settings spec rev 11 §4.3a): the source mirrors it from beside the
14// claim holder's lease in every round and in the cut's final round, and
15// the installer places it beside the destination's lease before the probe.
16// It is the only object under the lane's state/ prefix.
17func BuildStateKey(host, opID string) string {
18 return StagingPrefix(host, opID) + BuildStateSuffix
19}
20
21// BuildStateSuffix is BuildStateKey relative to the lane.
22const BuildStateSuffix = "state/build-state.json"
23
24// ScopeLocation is the lane as a park scope location: no trailing slash
25// (claim rev 6.23 §2 grammar, INV-23).
26func ScopeLocation(host, opID string) string { return "moves/" + host + "/" + opID }
27
28// MoveJSON is written create-only before the first round (§7.3). The
29// landing requires its incarnation.
30type MoveJSON struct {
31 MoveID string `json:"move_id"`
32 Incarnation string `json:"incarnation"`
33 Host string `json:"host"`
34 From string `json:"from"`
35 To string `json:"to"`
36}
37
38// LaneKey is T10's probe object in the source bucket (§7.3).
39func LaneKey(opID string) string { return "moves/_lane/" + opID }
40
41// Source-bucket keys: receipts and sealed snapshots, per operation (§6.3).
42func ReceiptsKey(host, opID string) string { return "move-receipts/" + host + "/" + opID + ".json" }
43func SnapshotsPrefix(host, opID string) string { return "move-snapshots/" + host + "/" + opID + "/" }
44
45// BuildStateReceiptsKey is the build-state lane's own copy receipts, beside
46// the replica lane's (settings spec rev 11 §4.3a).
47func BuildStateReceiptsKey(host, opID string) string { return ReceiptsKey(host, opID+"-state") }
48
49// LedgerKey is the per-operation ledger (the move_json_version and archive
50// seal facts the rounds record), beside the copy receipts and a different
51// object from them.
52func LedgerKey(host, opID string) string { return "move-receipts/" + host + "/" + opID + "-moves.json" }
53
54// Deployment-bucket keys (§5.3, §7.3, §13): reports, evidence and the log.
55func ReportPrefix(acct, app, host, opID string) string {
56 return "moves/" + acct + "/" + app + "/" + host + "/" + opID + "/"
57}
58func SourceReportKey(prefix string) string { return prefix + "source.json" }
59func TargetReportKey(prefix string) string { return prefix + "target.json" }
60func StoppedKey(prefix, role string) string { return prefix + "stopped-" + role + ".json" }
61
62// LogKeyFor is the move log object of one transition: its key is the
63// transition's identity (log.go), never a counter.
64func LogKeyFor(prefix, identity string) string {
65 return prefix + "log/" + identity + ".json"
66}
67
68// ProbeKey is where a target box measures regional S3 by putting and
69// getting a probe object (§7.3 T11). It is outside moves/ on purpose: the
70// target writes it with its own credentials and deletes it itself, and no
71// staging prefix, guarded list or mirror ever reaches it.
72func ProbeKey(host, opID string) string { return "move-probes/" + host + "/" + opID + "/probe" }
73