Documentation
¶
Index ¶
- Constants
- func Compare(a, b VClock) int
- func PeerCortexIDKey(peerName string) string
- func PeerCursorKey(peerName string) string
- func PeerSeenKey(peerName string) string
- type Config
- type EventReplayer
- type PeerConfig
- type PeerState
- type State
- func (s *State) Delete(key string) error
- func (s *State) Get(key string) (string, error)
- func (s *State) GetClock() (VClock, error)
- func (s *State) GetPeerState(name, endpoint string) (PeerState, error)
- func (s *State) Set(key, value string) error
- func (s *State) SetClock(vc VClock) error
- func (s *State) SetPeerCortexID(name, cortexID string) error
- func (s *State) SetPeerCursor(name, eventID string) error
- func (s *State) SetPeerSeen(name, timestamp string) error
- type Syncer
- type VClock
Constants ¶
const ( PeerModeSync = "sync" PeerModePaused = "paused" )
Peer mode constants — checked by the syncer to skip paused peers.
const DefaultInterval = 30 * time.Second
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
Compare returns the causal relationship between two clocks:
-1 means a happened-before b 0 means concurrent (no causal relationship — potential conflict) +1 means b happened-before a
func PeerCortexIDKey ¶
PeerCortexIDKey returns the federation_state key under which a peer's verified cortex ULID is pinned after the first successful identity handshake. The syncer refuses to talk to a peer whose advertised ID has changed from what is stored here — see docs/design/cortex-uuid-plan.md.
func PeerCursorKey ¶
PeerCursorKey returns the federation_state key for a peer's last_event cursor.
func PeerSeenKey ¶
PeerSeenKey returns the federation_state key for a peer's last_seen time.
Types ¶
type Config ¶
type Config struct {
Mode string // federation-level mode: sync | publish | subscribe
Peers []PeerConfig `yaml:"peers,omitempty"`
Interval time.Duration // parsed from string
// outbound request as "Authorization: Bearer <SharedKey>". Empty
// means open mode (no header sent). Populated at startup from
// cortex.LoadAccessKey; never surfaced in YAML, logs, or events.
SharedKey string `yaml:"-"`
}
Config holds federation settings from cortex.md.
func (Config) EffectiveInterval ¶
EffectiveInterval returns the configured interval or the default.
type EventReplayer ¶
EventReplayer materializes a remote event on the local cortex.
type PeerConfig ¶
type PeerConfig struct {
Name string `yaml:"name"`
Endpoint string `yaml:"endpoint"`
CA string `yaml:"ca,omitempty"` // path to CA certificate for TLS verification
Mode string `yaml:"mode,omitempty"` // sync | paused
}
PeerConfig is a peer entry as declared in cortex.md.
type PeerState ¶
type PeerState struct {
Name string
Endpoint string
LastSeen string // RFC3339, "" if never reached
LastEvent string // ULID of last synced event, "" if never synced
CortexID string // pinned ULID after first successful identity handshake
}
PeerState is the runtime state of a known peer.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State provides read/write access to the federation_state table.
func (*State) Delete ¶
Delete removes a single key from federation_state. Missing keys are not an error — Delete is used by `noema federation reset-peer` to clear pin / cursor / last_seen rows that may or may not exist depending on whether the peer has ever been contacted, so the operation has to be idempotent.
func (*State) GetPeerState ¶
GetPeerState loads the runtime state for a peer.
func (*State) SetPeerCortexID ¶
SetPeerCortexID pins a peer's verified cortex ULID. Should only be called after the cortex_identity handshake has succeeded once.
func (*State) SetPeerCursor ¶
SetPeerCursor updates the last synced event cursor for a peer.
func (*State) SetPeerSeen ¶
SetPeerSeen updates the last seen time for a peer.
type Syncer ¶
type Syncer struct {
// contains filtered or unexported fields
}
Syncer polls remote peers for new events and replays them locally.