Help us shape the future of Go! Take the 2026 Go Developer Survey

ocievents

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 26 Imported by: 0

README

OCI Events

Parity grade: B · SDK github.com/oracle/oci-go-sdk/v65@v65.126.2 · last audited 2026-10-29 (861afe5af)

Coverage

Metric Value
PARITY entries audited 6 (5 ok, 1 partial)
Feature families 10 (3 ok, 7 partial)
Known gaps 6
Deferred items 0
Resource leaks unknown
Known gaps
  • Event producers are limited to Object Storage objects and Functions applications and functions. Other services (including NoSQL, whose event names were not found in a reachable primary source) emit nothing; Functions update events, Object Storage bucket events and RenameObject do not emit.
  • Filter tags (matching on resource defined or freeform tags) and data.compartmentName are not produced, so conditions on them never match.
  • Unverified, chosen by the emulator: case-sensitive value comparison; numbers and booleans compared by their text form; unknown top-level condition keys are accepted and matched against the whole envelope; no rejection of conditions that can never match; rule displayName limit of 255 and no uniqueness rule.
  • Unverified, from memory: the 400 LimitExceeded code for the 50-rule limit, the eventrule/eventaction OCID prefixes, rules going ACTIVE with no CREATING state, 404 for a missing action target, lifecycleMessage always empty, and DELETE answering 204.
  • Delivery is best effort and unordered across events with no retry on Events' side; Oracle's real at-least-once and retry behaviour is not documented on the pages reached and is not reproduced. Delivery to ONS, OSS and FAAS in other compartments is not restricted.
  • opc-retry-token idempotency, IAM policy checks, resource principals and instance principals are not applied; only API-key signatures are verified. systemTags are never set. The dashboard has no OCI Events page.

More

Documentation

Index

Constants

View Source
const DefaultPort = 8164

DefaultPort is the dedicated listener's default TCP port.

View Source
const (
	// Region is the fixed region baked into emulated OCIDs.
	Region = "us-ashburn-1"
)

Variables

View Source
var ErrNilAppContext = errors.New("ocievents: nil app context")

ErrNilAppContext is returned when Init is called with a nil AppContext.

View Source
var ErrSnapshotNull = errors.New("ocievents: null entry in snapshot")

ErrSnapshotNull is returned when a snapshot contains a null entry.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code    string
	Message string
	Status  int
}

APIError is an OCI error response: HTTP status plus the `code` and `message` body fields.

func (*APIError) Error

func (e *APIError) Error() string

type Action

type Action struct {
	ID          string `json:"id"`
	ActionType  string `json:"actionType"`
	State       string `json:"lifecycleState"`
	Message     string `json:"lifecycleMessage"`
	Description string `json:"description,omitempty"`
	TopicID     string `json:"topicId,omitempty"`
	StreamID    string `json:"streamId,omitempty"`
	FunctionID  string `json:"functionId,omitempty"`
	IsEnabled   bool   `json:"isEnabled"`
}

Action is one destination of a rule.

type ActionList

type ActionList struct {
	Actions []*Action `json:"actions"`
}

ActionList is the wire wrapper of a rule's actions.

type ConfigProvider

type ConfigProvider interface {
	GetOCIEventsSettings() Settings
}

ConfigProvider extracts OCI Events configuration from the AppContext Config.

type Delivery

type Delivery struct {
	Time       time.Time `json:"time"`
	EventID    string    `json:"eventId"`
	EventType  string    `json:"eventType"`
	RuleID     string    `json:"ruleId"`
	ActionID   string    `json:"actionId"`
	ActionType string    `json:"actionType"`
	TargetID   string    `json:"targetId"`
	Status     string    `json:"status"`
	Error      string    `json:"error,omitempty"`
}

Delivery records one attempt to hand an event to a rule action; failed attempts are not retried.

type Event

type Event struct {
	Time               time.Time
	AdditionalDetails  map[string]any
	EventType          string
	Source             string
	CompartmentID      string
	ResourceName       string
	ResourceID         string
	AvailabilityDomain string
}

Event is what a service reports; the backend wraps it in the OCI event envelope.

type FunctionInvoker

type FunctionInvoker interface {
	FunctionActive(id string) bool
	InvokeFunction(ctx context.Context, functionID string, body []byte) error
}

FunctionInvoker invokes a function with an event as its payload; wired to OCI Functions in internal/app.

type Handler

type Handler struct {
	Backend *InMemoryBackend

	Port        int
	EnforceAuth bool
	// contains filtered or unexported fields
}

Handler serves OCI Events: rules and the event delivery log.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler creates a Handler; callers override Port and EnforceAuth from Settings.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation returns the operation name for metrics.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource returns the addressed resource id for metrics.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations lists the supported operations.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the Echo handler for all OCIEvents requests.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority is irrelevant because RouteMatcher never matches.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all in-memory state.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher never matches: OCIEvents runs on its own listener.

func (*Handler) Shutdown

func (h *Handler) Shutdown(ctx context.Context)

Shutdown stops the listener and waits for in-flight deliveries.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker binds the dedicated listener synchronously so a port conflict is returned to the caller.

func (*Handler) Trusted

func (h *Handler) Trusted() echo.HandlerFunc

Trusted returns a handler that skips request-signature verification, for the in-process dashboard proxy.

type InMemoryBackend

type InMemoryBackend struct {
	Auth *ociauth.Registry
	// contains filtered or unexported fields
}

InMemoryBackend holds every rule under one lock.

func NewInMemoryBackend

func NewInMemoryBackend() *InMemoryBackend

NewInMemoryBackend creates an empty backend that delivers events on goroutines tracked by Wait.

func (*InMemoryBackend) ChangeRuleCompartment

func (b *InMemoryBackend) ChangeRuleCompartment(id, ifMatch string, in changeCompartmentIn) error

ChangeRuleCompartment moves a rule.

func (*InMemoryBackend) Compartments

func (b *InMemoryBackend) Compartments() []string

Compartments lists the distinct compartments that hold rules.

func (*InMemoryBackend) CreateRule

func (b *InMemoryBackend) CreateRule(in createRuleIn) (RuleWire, string, error)

CreateRule creates a rule.

func (*InMemoryBackend) DeleteRule

func (b *InMemoryBackend) DeleteRule(id, ifMatch string) error

DeleteRule deletes a rule; it stays readable with state DELETED.

func (*InMemoryBackend) Deliveries

func (b *InMemoryBackend) Deliveries() []Delivery

Deliveries returns the delivery log, oldest first.

func (*InMemoryBackend) Emit

func (b *InMemoryBackend) Emit(ev Event)

Emit matches an event against every enabled rule that covers its compartment and delivers it to the enabled actions of each matching rule.

func (*InMemoryBackend) GetRule

func (b *InMemoryBackend) GetRule(id string) (RuleWire, string, error)

GetRule returns one rule and its etag; a deleted rule is still reported with state DELETED.

func (*InMemoryBackend) ListRules

func (b *InMemoryBackend) ListRules(compartment, name, state string, o ListOpts) (page.Page[RuleSummaryWire], error)

ListRules lists the rules of a compartment; DELETED rules are hidden unless filtered for.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all state.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads backend state from a snapshot.

func (*InMemoryBackend) SetClock

func (b *InMemoryBackend) SetClock(now func() time.Time)

SetClock injects the time source for timestamps and delivery records.

func (*InMemoryBackend) SetCompartmentChecker

func (b *InMemoryBackend) SetCompartmentChecker(fn func(string) bool)

SetCompartmentChecker validates compartmentId arguments against another service (OCI Identity).

func (*InMemoryBackend) SetCompartmentTree

func (b *InMemoryBackend) SetCompartmentTree(fn func(id, ancestor string) bool)

SetCompartmentTree tells the backend whether a compartment is nested below another (OCI Identity).

func (*InMemoryBackend) SetDispatcher

func (b *InMemoryBackend) SetDispatcher(fn func(func()))

SetDispatcher replaces how deliveries are run; tests pass a function that runs them inline.

func (*InMemoryBackend) SetFunctionInvoker

func (b *InMemoryBackend) SetFunctionInvoker(f FunctionInvoker)

SetFunctionInvoker wires the FAAS action target.

func (*InMemoryBackend) SetNotifier

func (b *InMemoryBackend) SetNotifier(n Notifier)

SetNotifier wires the ONS action target.

func (*InMemoryBackend) SetStreamer

func (b *InMemoryBackend) SetStreamer(s Streamer)

SetStreamer wires the OSS action target.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the rules and registered API keys; the delivery log is not persisted.

func (*InMemoryBackend) UpdateRule

func (b *InMemoryBackend) UpdateRule(id, ifMatch string, in updateRuleIn) (RuleWire, string, error)

UpdateRule changes the mutable attributes of a rule.

func (*InMemoryBackend) Wait

func (b *InMemoryBackend) Wait()

Wait blocks until every in-flight delivery has finished.

type ListOpts

type ListOpts struct {
	SortBy string
	Order  string
	Page   string
	Limit  int
}

ListOpts carries the shared list query parameters.

type Notifier

type Notifier interface {
	TopicActive(id string) bool
	PublishEvent(topicID, body string) error
}

Notifier publishes an event message to an ONS topic; wired to OCI Notifications in internal/app.

type Provider

type Provider struct{}

Provider implements service.Provider for OCI Events. It runs on its own listener (see Handler.StartWorker) and never matches on the shared AWS router.

func (*Provider) Init

Init creates the backend and handler; the port is bound in StartWorker.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the service provider name.

type Rule

type Rule struct {
	TimeCreated   time.Time `json:"timeCreated"`
	Tags          Tags      `json:"tags"`
	ID            string    `json:"id"`
	DisplayName   string    `json:"displayName"`
	Description   string    `json:"description,omitempty"`
	Condition     string    `json:"condition"`
	CompartmentID string    `json:"compartmentId"`
	State         string    `json:"state"`
	Etag          string    `json:"etag"`
	Actions       []*Action `json:"actions"`
	Seq           int64     `json:"seq"`
	IsEnabled     bool      `json:"isEnabled"`
}

Rule is an Events rule.

type RuleSummaryWire

type RuleSummaryWire struct {
	TimeCreated    time.Time                 `json:"timeCreated"`
	DefinedTags    map[string]map[string]any `json:"definedTags,omitempty"`
	FreeformTags   map[string]string         `json:"freeformTags,omitempty"`
	ID             string                    `json:"id"`
	DisplayName    string                    `json:"displayName"`
	Description    string                    `json:"description,omitempty"`
	Condition      string                    `json:"condition"`
	CompartmentID  string                    `json:"compartmentId"`
	LifecycleState string                    `json:"lifecycleState"`
	IsEnabled      bool                      `json:"isEnabled"`
}

RuleSummaryWire is the wire form of a rule in a list.

type RuleWire

type RuleWire struct {
	TimeCreated      time.Time                 `json:"timeCreated"`
	DefinedTags      map[string]map[string]any `json:"definedTags,omitempty"`
	FreeformTags     map[string]string         `json:"freeformTags,omitempty"`
	ID               string                    `json:"id"`
	DisplayName      string                    `json:"displayName"`
	Description      string                    `json:"description,omitempty"`
	Condition        string                    `json:"condition"`
	CompartmentID    string                    `json:"compartmentId"`
	LifecycleState   string                    `json:"lifecycleState"`
	LifecycleMessage string                    `json:"lifecycleMessage"`
	Actions          ActionList                `json:"actions"`
	IsEnabled        bool                      `json:"isEnabled"`
}

RuleWire is the wire form of a rule.

type Settings

type Settings struct {
	Port int `` //nolint:lll // config struct tags are intentionally verbose
	/* 180-byte string literal not displayed */
	EnforceAuth bool `` //nolint:lll // config struct tags are intentionally verbose
	/* 236-byte string literal not displayed */
}

Settings holds service-level configuration, embedded in the root CLI as CLI.OCIEvents.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns the settings used when no ConfigProvider is available.

type Streamer

type Streamer interface {
	StreamActive(id string) bool
	AppendMessage(streamID string, key, value []byte) error
}

Streamer appends an event message to a stream; wired to OCI Streaming in internal/app.

type Tags

type Tags struct {
	FreeformTags map[string]string         `json:"freeformTags,omitempty"`
	DefinedTags  map[string]map[string]any `json:"definedTags,omitempty"`
}

Tags are the shared freeform and defined tag sets of a resource.

Jump to

Keyboard shortcuts

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