Documentation
¶
Index ¶
Constants ¶
View Source
const ( // Token lifecycle TokenCreated = "token.created" TokenUpdated = "token.updated" TokenDeleted = "token.deleted" TokenExpired = "token.expired" // Policy rule matches RuleViolation = "rule.violation" RuleWarning = "rule.warning" RuleMatch = "rule.match" RuleMask = "rule.mask" // Budget and rate limiting BudgetExceeded = "budget.exceeded" BudgetUpdate = "budget.update" RateExceeded = "rate.exceeded" // Request lifecycle RequestCompleted = "request.completed" // OpenClaw integration OpenClawAgentRequest = "openclaw.agent.request" OpenClawAgentSuccess = "openclaw.agent.success" OpenClawAgentError = "openclaw.agent.error" OpenClawRuleViolation = "openclaw.rule.violation" // System ServerStart = "server.start" )
Event types emitted by Tokenomics.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Emitter ¶
type Emitter interface {
// Emit delivers an event. Implementations should be non-blocking
// or use their own internal queue to avoid slowing the caller.
Emit(ctx context.Context, event Event) error
// Close flushes pending events and releases resources.
Close() error
}
Emitter is the interface for delivering events to external systems. Implementations include webhooks, message buses, log sinks, etc.
type Event ¶
type Event struct {
ID string `json:"id"`
Type string `json:"type"`
Timestamp string `json:"timestamp"`
Data map[string]interface{} `json:"data,omitempty"`
}
Event is the payload delivered to emitters.
type Multi ¶
type Multi struct {
// contains filtered or unexported fields
}
Multi fans out events to multiple emitters.
type WebhookConfig ¶
type WebhookConfig struct {
URL string `mapstructure:"url" json:"url"`
Secret string `mapstructure:"secret" json:"secret,omitempty"` // Shared secret sent as X-Webhook-Secret header
SigningKey string `mapstructure:"signing_key" json:"signing_key,omitempty"` // HMAC-SHA256 signing key; signature sent as X-Webhook-Signature
Events []string `mapstructure:"events" json:"events,omitempty"` // Event type filter (supports trailing * wildcard); empty = all
TimeoutSec int `mapstructure:"timeout" json:"timeout,omitempty"` // HTTP timeout in seconds (default 10)
Insecure bool `mapstructure:"insecure" json:"insecure,omitempty"` // Skip TLS certificate verification (for self-signed certs)
}
WebhookConfig configures a single webhook endpoint.
type WebhookEmitter ¶
type WebhookEmitter struct {
// contains filtered or unexported fields
}
WebhookEmitter delivers events to an HTTP endpoint.
func NewWebhookEmitter ¶
func NewWebhookEmitter(cfg WebhookConfig) *WebhookEmitter
NewWebhookEmitter creates a webhook emitter that sends events asynchronously. Events are buffered in a channel and delivered in a background goroutine.
func (*WebhookEmitter) Close ¶
func (w *WebhookEmitter) Close() error
Close drains the queue and shuts down the worker.
Click to show internal directories.
Click to hide internal directories.