types: add when a node's run of control sessions began

This commit is contained in:
Kristoffer Dalby committed 2026-10-30 14:55:36 +00:00
1 parent 160302e920
commit 41dc97401b
4 files changed
+16 -2

No files matched your search

+1 -1
View File
@@ -1912,7 +1912,7 @@ var nodeFieldImpact = map[string]string{
"RegisterMethod": "payload", "AuthKeyID": "payload", "AuthKey": "payload",
"Expiry": "election", "LastSeen": "payload", "CreatedAt": "payload",
"UpdatedAt": "payload", "DeletedAt": "payload",
"ActiveSessions": "payload", "SessionEpoch": "payload",
"ActiveSessions": "payload", "SessionEpoch": "payload", "SessionStart": "election",
}
// TestUpdateChangesCoversEveryNodeField guards against a new types.Node
+6
View File
@@ -210,6 +210,12 @@ type Node struct {
// returned by Connect as a "Connect ran" sentinel for its cleanup,
// and Disconnect logs it. Runtime-only.
SessionEpoch uint64 `gorm:"-"`
// SessionStart is when the node's current run of control sessions
// began: [State.Connect] sets it as the first of them opens, and an
// overlapping reconnect keeps it. Primary election prefers the
// oldest. Runtime-only.
SessionStart time.Time `gorm:"-"`
}
type Nodes []*Node
+1
View File
@@ -108,6 +108,7 @@ var _NodeCloneNeedsRegeneration = Node(struct {
Unhealthy bool
ActiveSessions int
SessionEpoch uint64
SessionStart time.Time
}{})
// Clone makes a deep copy of PreAuthKey.
+8 -1
View File
@@ -281,7 +281,13 @@ func (v NodeView) ActiveSessions() int { return v.ж.ActiveSessions }
// returned by Connect as a "Connect ran" sentinel for its cleanup,
// and Disconnect logs it. Runtime-only.
func (v NodeView) SessionEpoch() uint64 { return v.ж.SessionEpoch }
func (v NodeView) String() string { return v.ж.String() }
// SessionStart is when the node's current run of control sessions
// began: [State.Connect] sets it as the first of them opens, and an
// overlapping reconnect keeps it. Primary election prefers the
// oldest. Runtime-only.
func (v NodeView) SessionStart() time.Time { return v.ж.SessionStart }
func (v NodeView) String() string { return v.ж.String() }
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _NodeViewNeedsRegeneration = Node(struct {
@@ -311,6 +317,7 @@ var _NodeViewNeedsRegeneration = Node(struct {
Unhealthy bool
ActiveSessions int
SessionEpoch uint64
SessionStart time.Time
}{})
// View returns a read-only view of PreAuthKey.