opevents

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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 AWSSQSSinkConfig struct {
	QueueURL        string
	AccessKeyID     string `json:"-"`
	SecretAccessKey string `json:"-"`
	Region          string
	Endpoint        string // optional, for local dev
}

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

func NewEmitter(sink Sink, deploymentID string, topics []string, logger *logging.Logger) Emitter

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

func AttemptFailedEvent(dest *AlertDestination, event *models.Event, attempt *models.Attempt) Event

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 GCPPubSubSinkConfig struct {
	ProjectID                 string
	TopicID                   string
	ServiceAccountCredentials string `json:"-"`
}

type HTTPSink

type HTTPSink struct {
	// contains filtered or unexported fields
}

HTTPSink sends operator events via HTTP POST with optional HMAC-SHA256 signing.

func NewHTTPSink

func NewHTTPSink(url, signingSecret string) *HTTPSink

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.

func (*HTTPSink) Close

func (s *HTTPSink) Close() error

func (*HTTPSink) Init

func (s *HTTPSink) Init(ctx context.Context) error

func (*HTTPSink) Send

func (s *HTTPSink) Send(ctx context.Context, event *OperatorEvent) error

type HTTPSinkConfig

type HTTPSinkConfig struct {
	URL           string
	SigningSecret string `json:"-"`
}

type MQSink

type MQSink struct {
	// contains filtered or unexported fields
}

MQSink sends operator events to a message queue via mqs.Queue.

func NewMQSink

func NewMQSink(queue mqs.Queue) *MQSink

NewMQSink creates a sink that publishes events to the given queue.

func (*MQSink) Close

func (s *MQSink) Close() error

func (*MQSink) Init

func (s *MQSink) Init(ctx context.Context) error

func (*MQSink) Send

func (s *MQSink) Send(ctx context.Context, event *OperatorEvent) error

type NoopSink

type NoopSink struct{}

NoopSink is a sink that discards all events. Used when no sink is configured.

func (*NoopSink) Close

func (s *NoopSink) Close() error

func (*NoopSink) Init

func (s *NoopSink) Init(ctx context.Context) error

func (*NoopSink) Send

func (s *NoopSink) Send(ctx context.Context, event *OperatorEvent) error

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 RabbitMQSinkConfig struct {
	ServerURL string
	Exchange  string
}

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.

func NewSink

func NewSink(cfg Config, logger *logging.Logger) (Sink, error)

NewSink returns the appropriate Sink based on config. Returns NoopSink if no sink is configured. If topics are specified but no sink is configured, it logs a warning and returns NoopSink (operator events will be dropped).

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL