Documentation
¶
Overview ¶
Package listener defines the EventSource interface and shared event types for Vela's real-time update system. Sources (Ancora, future modules) connect via IPC and emit events that drive incremental graph reconciliation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AncoraListener ¶
type AncoraListener struct {
// contains filtered or unexported fields
}
AncoraListener connects to the Ancora IPC socket and relays events to Vela's reconciler. It implements automatic reconnection with exponential backoff.
func NewAncoraListener ¶
func NewAncoraListener(socketPath, secretPath string) *AncoraListener
NewAncoraListener creates a listener for the Ancora IPC socket. socketPath and secretPath may be empty — defaults under ~/.syfra/ are used.
func (*AncoraListener) Connect ¶
func (a *AncoraListener) Connect(ctx context.Context) error
Connect starts the background reader goroutine. Returns immediately. If the socket is unavailable the goroutine will retry automatically.
func (*AncoraListener) Events ¶
func (a *AncoraListener) Events() <-chan Event
Events implements EventSource.
func (*AncoraListener) Status ¶
func (a *AncoraListener) Status() SourceStatus
Status implements EventSource.
type Event ¶
type Event struct {
// Source is the name of the listener that produced this event (e.g. "ancora").
Source string
Type EventType
Payload json.RawMessage
Timestamp time.Time
}
Event is a single change notification received from an event source. It is the internal Vela representation — decoupled from the wire format.
type EventSource ¶
type EventSource interface {
// Name returns a stable, human-readable identifier (e.g. "ancora").
Name() string
// Connect establishes the connection to the source. Implementations should
// start a background reader goroutine and return immediately. If the source
// is unavailable, Connect may return an error — callers should retry.
Connect(ctx context.Context) error
// Events returns a read-only channel of incoming events. The channel is
// closed when the source disconnects or Close is called.
Events() <-chan Event
// Close disconnects from the source and releases resources.
Close() error
// Status returns a snapshot of the current connection status.
Status() SourceStatus
}
EventSource is the interface that all event listeners must implement. Implementations must be safe for concurrent use.
type EventType ¶
type EventType string
EventType identifies the kind of change emitted by an event source.
type ObservationDeletedPayload ¶
ObservationDeletedPayload is the slim payload for deleted observations.
type ObservationPayload ¶
type ObservationPayload struct {
ID int64 `json:"id"`
SyncID string `json:"sync_id"`
SessionID string `json:"session_id"`
Type string `json:"type"`
Title string `json:"title"`
Content string `json:"content"`
Workspace string `json:"workspace,omitempty"`
Visibility string `json:"visibility"`
Organization string `json:"organization,omitempty"`
TopicKey string `json:"topic_key,omitempty"`
References []Reference `json:"references,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ObservationPayload is the full event payload for created/updated observations.
type Reference ¶
type Reference struct {
// Type is one of: "file", "observation", "concept", "function"
Type string `json:"type"`
// Target is the referenced artifact (file path, observation ID, concept name, etc.)
Target string `json:"target"`
}
Reference describes a relationship from an observation to another artifact.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages a set of EventSources and fans their events out onto a single merged channel. Sources can be added or removed at runtime.
func NewRegistry ¶
func NewRegistry() *Registry
NewRegistry creates an empty registry. Call Run to start the fan-in loop.
func (*Registry) Add ¶
func (r *Registry) Add(ctx context.Context, src EventSource) error
Add registers an EventSource. If a source with the same name already exists it is replaced (the old one is closed first). Add is safe to call concurrently and after Run has started.
func (*Registry) Close ¶
func (r *Registry) Close()
Close shuts down all sources and the merged channel.
func (*Registry) Statuses ¶
func (r *Registry) Statuses() map[string]SourceStatus
Statuses returns a snapshot of all source statuses keyed by name.