Documentation
¶
Overview ¶
Package event owns the EventKey registry, RawEvent, APIClient, and dedup filter.
Index ¶
- Constants
- func RegisterKey(def KeyDefinition)
- func ResetRegistryForTest()
- func SanitizeAppID(appID string) string
- func UnregisterKeyForTest(key string)
- type APIClient
- type DedupFilter
- type KeyDefinition
- type ParamDef
- type ParamType
- type ParamValue
- type ProcessFunc
- type RawEvent
- type SchemaDef
- type SchemaSpec
Constants ¶
const ( DefaultBufferSize = 100 MaxBufferSize = 1000 )
Variables ¶
This section is empty.
Functions ¶
func RegisterKey ¶
func RegisterKey(def KeyDefinition)
RegisterKey panics on duplicate Key, empty EventType, or schema/process contract violations.
func ResetRegistryForTest ¶
func ResetRegistryForTest()
func SanitizeAppID ¶
SanitizeAppID replaces ".." / path separators / NUL with "_" to guard filepath.Join; empty/dot-only collapses to "_".
func UnregisterKeyForTest ¶
func UnregisterKeyForTest(key string)
UnregisterKeyForTest removes one key — use this (not Reset) in tests with synthetic keys alongside production keys to keep -count=N reruns idempotent.
Types ¶
type APIClient ¶
type APIClient interface {
CallAPI(ctx context.Context, method, path string, body interface{}) (json.RawMessage, error)
}
APIClient: identity is opaque so business code can't bypass pre-flight checks.
type DedupFilter ¶
type DedupFilter struct {
// contains filtered or unexported fields
}
DedupFilter: seen map is sole authority; ring only bounds map size via overflow eviction.
func NewDedupFilter ¶
func NewDedupFilter() *DedupFilter
func NewDedupFilterWithSize ¶
func NewDedupFilterWithSize(ringSize int, ttl time.Duration) *DedupFilter
func (*DedupFilter) IsDuplicate ¶
func (d *DedupFilter) IsDuplicate(eventID string) bool
type KeyDefinition ¶
type KeyDefinition struct {
Key string `json:"key"`
DisplayName string `json:"display_name,omitempty"`
Description string `json:"description,omitempty"`
EventType string `json:"event_type"`
Params []ParamDef `json:"params,omitempty"`
Schema SchemaDef `json:"schema"`
// Process required when Schema.Custom is Processed output; must be nil when Native is used.
Process func(ctx context.Context, rt APIClient, raw *RawEvent, params map[string]string) (json.RawMessage, error) `json:"-"`
PreConsume func(ctx context.Context, rt APIClient, params map[string]string) (cleanup func(), err error) `json:"-"`
Scopes []string `json:"scopes,omitempty"`
// AuthTypes: whitelist of identities the EventKey accepts. Empty = no identity required.
AuthTypes []string `json:"auth_types,omitempty"`
RequiredConsoleEvents []string `json:"required_console_events,omitempty"`
BufferSize int `json:"buffer_size,omitempty"`
Workers int `json:"workers,omitempty"`
}
func Lookup ¶
func Lookup(key string) (*KeyDefinition, bool)
type ParamValue ¶
ParamValue.Desc is mandatory so AI consumers can decide which value to pick.
type ProcessFunc ¶
type RawEvent ¶
type RawEvent struct {
EventID string `json:"event_id"`
EventType string `json:"event_type"`
SourceTime string `json:"source_time,omitempty"`
Payload json.RawMessage `json:"payload"`
Timestamp time.Time `json:"timestamp"`
}
RawEvent: SourceTime is upstream create_time; Timestamp is local source observation time.
type SchemaDef ¶
type SchemaDef struct {
Native *SchemaSpec `json:"native,omitempty"`
Custom *SchemaSpec `json:"custom,omitempty"`
FieldOverrides map[string]schemas.FieldMeta `json:"field_overrides,omitempty"`
}
SchemaDef: exactly one of Native or Custom must be set. Native auto-wraps the SDK type in the V2 envelope; Custom passes through verbatim.
type SchemaSpec ¶
type SchemaSpec struct {
Type reflect.Type `json:"-"`
Raw json.RawMessage `json:"raw,omitempty"`
}
SchemaSpec: exactly one of Type or Raw.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package bus implements the per-AppID event-bus daemon; lifecycle is driven by consumer presence (idle timeout) and explicit shutdown.
|
Package bus implements the per-AppID event-bus daemon; lifecycle is driven by consumer presence (idle timeout) and explicit shutdown. |
|
Package busctl is the wire-level control client for the event bus daemon.
|
Package busctl is the wire-level control client for the event bus daemon. |
|
Package busdiscover enumerates live bus daemons via per-AppID PID files protected by a process-lifetime advisory lock.
|
Package busdiscover enumerates live bus daemons via per-AppID PID files protected by a process-lifetime advisory lock. |
|
Package consume drives the consume-side half of the events pipeline.
|
Package consume drives the consume-side half of the events pipeline. |
|
Package protocol defines the newline-delimited JSON wire format used over IPC.
|
Package protocol defines the newline-delimited JSON wire format used over IPC. |
|
Package schemas derives JSON Schema fragments from Go types via reflection.
|
Package schemas derives JSON Schema fragments from Go types via reflection. |
|
Package source is a pluggable event source abstraction (separate package to keep business registrations free of SDK transitive deps).
|
Package source is a pluggable event source abstraction (separate package to keep business registrations free of SDK transitive deps). |
|
Package testutil holds test-only helpers shared across event subsystem tests.
|
Package testutil holds test-only helpers shared across event subsystem tests. |
|
Package transport: Unix sockets on POSIX, named pipes on Windows.
|
Package transport: Unix sockets on POSIX, named pipes on Windows. |