Documentation
¶
Index ¶
- Constants
- type AWSSQSSinkConfig
- type AlertDestination
- type AttemptData
- type Config
- type ConsecutiveFailureData
- type ConsecutiveFailures
- type DestinationDisabledData
- type Emitter
- type Event
- func AttemptFailedEvent(dest *AlertDestination, event *models.Event, attempt *models.Attempt) Event
- func AttemptSuccessEvent(dest *AlertDestination, event *models.Event, attempt *models.Attempt) Event
- func ConsecutiveFailureEvent(dest *AlertDestination, event *models.Event, attempt *models.Attempt, ...) Event
- func DestinationDisabledEvent(dest *AlertDestination, event *models.Event, attempt *models.Attempt, ...) Event
- func ExhaustedRetriesEvent(dest *AlertDestination, event *models.Event, attempt *models.Attempt) Event
- func TenantSubscriptionUpdatedEvent(data TenantSubscriptionUpdatedData) Event
- type ExhaustedRetriesData
- type GCPPubSubSinkConfig
- type HTTPSink
- type HTTPSinkConfig
- type MQSink
- type NoopSink
- type OperatorEvent
- type RabbitMQSinkConfig
- type Sink
- type TenantSubscriptionUpdatedData
Constants ¶
const ( TopicAlertConsecutiveFailure = "alert.destination.consecutive_failure" TopicAlertDestinationDisabled = "alert.destination.disabled" TopicAlertExhaustedRetries = "alert.attempt.exhausted_retries" TopicAttemptSuccess = "attempt.success" TopicAttemptFailed = "attempt.failed" TopicTenantSubscriptionUpdated = "tenant.subscription.updated" )
Topic constants for operator events.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AWSSQSSinkConfig ¶
type AlertDestination ¶ added in v1.1.0
type AlertDestination struct {
ID string `json:"id"`
TenantID string `json:"tenant_id"`
Type string `json:"type"`
Topics models.Topics `json:"topics"`
Config models.Config `json:"config"`
CreatedAt time.Time `json:"created_at"`
DisabledAt *time.Time `json:"disabled_at"`
}
AlertDestination is the destination projection included in alert payloads.
func NewAlertDestination ¶ added in v1.1.0
func NewAlertDestination(d *models.Destination) *AlertDestination
NewAlertDestination projects a models.Destination into the payload shape.
type AttemptData ¶ added in v1.1.0
type AttemptData struct {
TenantID string `json:"tenant_id"`
Event *models.Event `json:"event"`
Attempt *models.Attempt `json:"attempt"`
Destination *AlertDestination `json:"destination"`
}
AttemptData is the data payload for attempt.success and attempt.failed events. The two topics share one shape — the split exists for subscription filtering, and Attempt.Status carries the outcome.
type Config ¶
type Config struct {
Topics []string
// Sink configs — at most one should be set. Presence determines sink type.
HTTP *HTTPSinkConfig
AWSSQS *AWSSQSSinkConfig
GCPPubSub *GCPPubSubSinkConfig
RabbitMQ *RabbitMQSinkConfig
}
Config holds the configuration for the operator events system. yaml/env tags live in internal/config; this is the domain-level struct.
type ConsecutiveFailureData ¶ added in v1.1.0
type ConsecutiveFailureData struct {
TenantID string `json:"tenant_id"`
Event *models.Event `json:"event"`
Attempt *models.Attempt `json:"attempt"`
Destination *AlertDestination `json:"destination"`
ConsecutiveFailures ConsecutiveFailures `json:"consecutive_failures"`
}
ConsecutiveFailureData is the data payload for alert.destination.consecutive_failure events.
type ConsecutiveFailures ¶ added in v1.1.0
type ConsecutiveFailures struct {
Current int `json:"current"`
Max int `json:"max"`
Threshold int `json:"threshold"`
}
ConsecutiveFailures represents the nested consecutive failure state.
type DestinationDisabledData ¶ added in v1.1.0
type DestinationDisabledData struct {
TenantID string `json:"tenant_id"`
Destination *AlertDestination `json:"destination"`
DisabledAt time.Time `json:"disabled_at"`
Reason string `json:"reason"`
Event *models.Event `json:"event"`
Attempt *models.Attempt `json:"attempt"`
}
DestinationDisabledData is the data payload for alert.destination.disabled events.
type Emitter ¶
type Emitter interface {
Emit(ctx context.Context, ev Event) error
// Enabled reports whether events on topic would be sent rather than
// discarded by the topic filter. Lets callers skip building events that
// would be dropped.
Enabled(topic string) bool
}
Emitter is the interface for emitting operator events.
func NewEmitter ¶
NewEmitter creates an Emitter that filters by topics, builds the envelope, and delegates to the provided Sink. If topics contains "*", all topics are accepted. If topics is empty, a noop emitter is returned. The emitter owns the delivery audit log: a line is written iff an event was actually sent — filtered topics and the noop emitter return nil without logging.
type Event ¶ added in v1.1.0
type Event struct {
Topic string
TenantID string
Data any
// LogFields is caller context attached to the delivery audit line —
// typically set by the payload constructors, not at emit call sites.
LogFields []zap.Field
}
Event is a request to emit an operator event. Callers (alert eval, apirouter) build it and hand it to Emit, which owns envelope construction and delivery.
func AttemptFailedEvent ¶ added in v1.1.0
AttemptFailedEvent builds the attempt.failed event.
func AttemptSuccessEvent ¶ added in v1.1.0
func AttemptSuccessEvent(dest *AlertDestination, event *models.Event, attempt *models.Attempt) Event
AttemptSuccessEvent builds the attempt.success event.
func ConsecutiveFailureEvent ¶ added in v1.1.0
func ConsecutiveFailureEvent(dest *AlertDestination, event *models.Event, attempt *models.Attempt, current, max, threshold int) Event
ConsecutiveFailureEvent builds the alert.destination.consecutive_failure event.
func DestinationDisabledEvent ¶ added in v1.1.0
func DestinationDisabledEvent(dest *AlertDestination, event *models.Event, attempt *models.Attempt, disabledAt time.Time) Event
DestinationDisabledEvent builds the alert.destination.disabled event.
func ExhaustedRetriesEvent ¶ added in v1.1.0
func ExhaustedRetriesEvent(dest *AlertDestination, event *models.Event, attempt *models.Attempt) Event
ExhaustedRetriesEvent builds the alert.attempt.exhausted_retries event.
func TenantSubscriptionUpdatedEvent ¶ added in v1.1.0
func TenantSubscriptionUpdatedEvent(data TenantSubscriptionUpdatedData) Event
TenantSubscriptionUpdatedEvent builds the tenant.subscription.updated event.
type ExhaustedRetriesData ¶ added in v1.1.0
type ExhaustedRetriesData struct {
TenantID string `json:"tenant_id"`
Event *models.Event `json:"event"`
Attempt *models.Attempt `json:"attempt"`
Destination *AlertDestination `json:"destination"`
}
ExhaustedRetriesData is the data payload for alert.attempt.exhausted_retries events.
type GCPPubSubSinkConfig ¶
type HTTPSink ¶
type HTTPSink struct {
// contains filtered or unexported fields
}
HTTPSink sends operator events via HTTP POST with optional HMAC-SHA256 signing.
func NewHTTPSink ¶
NewHTTPSink creates an HTTP sink. If signingSecret is non-empty, each request body is signed with HMAC-SHA256 and the signature is sent in the X-Outpost-Signature header.
type HTTPSinkConfig ¶
type MQSink ¶
type MQSink struct {
// contains filtered or unexported fields
}
MQSink sends operator events to a message queue via mqs.Queue.
type NoopSink ¶
type NoopSink struct{}
NoopSink is a sink that discards all events. Used when no sink is configured.
type OperatorEvent ¶
type OperatorEvent struct {
ID string `json:"id"`
Topic string `json:"topic"`
Time time.Time `json:"time"`
DeploymentID string `json:"deployment_id,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
Data json.RawMessage `json:"data"`
}
OperatorEvent is the envelope for all operator events emitted by Outpost.
type RabbitMQSinkConfig ¶
type Sink ¶
type Sink interface {
Init(ctx context.Context) error
Send(ctx context.Context, event *OperatorEvent) error
Close() error
}
Sink is the interface for delivering operator events to an external system.
type TenantSubscriptionUpdatedData ¶ added in v1.1.0
type TenantSubscriptionUpdatedData struct {
TenantID string `json:"tenant_id"`
Topics []string `json:"topics"`
PreviousTopics []string `json:"previous_topics"`
DestinationsCount int `json:"destinations_count"`
PreviousDestinationsCount int `json:"previous_destinations_count"`
}
TenantSubscriptionUpdatedData is the data payload for tenant.subscription.updated events.