J2: a state read carries the time the bus wrote the value, as at (stdio.StateEntry.At)

Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
This commit is contained in:
2026-11-04 14:31:36 +01:00
parent f87c9720ed
commit 76e025dbbc
4 changed files with 7 additions and 4 deletions
+3 -1
View File
@@ -39,6 +39,8 @@ type StateEntry struct {
Key string `json:"key"`
Value json.RawMessage `json:"value"`
Revision uint64 `json:"revision"`
// At is when the bus wrote this value (the entry's created time), as stdio.StateEntry.At reads it.
At time.Time `json:"at,omitzero"`
}
// StateChange is one change a watch delivers: a key put, deleted, or expired (its own time to live, or the
@@ -134,7 +136,7 @@ func (c *Conn) StateGet(module, name, key string) (*StateEntry, error) {
if err != nil {
return nil, err
}
return &StateEntry{Key: e.Key(), Value: valueOf(e.Value()), Revision: e.Revision()}, nil
return &StateEntry{Key: e.Key(), Value: valueOf(e.Value()), Revision: e.Revision(), At: e.Created().UTC()}, nil
}
// StateKept is one value a bucket still keeps for a key: a put, or a delete (a purge reads as one).