eventbridge

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package eventbridge is doze-aws's local EventBridge: event buses, rules with the full content-based pattern language (internal/eventpattern), and synchronous delivery to SQS and Lambda targets with Input / InputPath / InputTransformer shaping.

rate(...) scheduled rules are driven by a local ticker; cron(...) and destinations, partner event sources, and the schemas registry are cloud infrastructure and answer honestly.

See docs/api-support/eventbridge.md for the operation table.

Index

Constants

View Source
const DefaultBus = "default"

DefaultBus is the implicit bus every account has.

Variables

This section is empty.

Functions

This section is empty.

Types

type Archive added in v0.2.0

type Archive struct {
	Name           string `json:"name"`
	EventSourceArn string `json:"source_arn"` // bus ARN
	Pattern        string `json:"pattern,omitempty"`
	RetentionDays  int    `json:"retention_days,omitempty"`
	Desc           string `json:"desc,omitempty"`
	State          string `json:"state"`
	CreationTime   int64  `json:"created"` // unix seconds
	EventCount     int64  `json:"event_count"`
	SizeBytes      int64  `json:"size_bytes"`
}

Archive is an event archive over one bus.

func (*Archive) ARN added in v0.2.0

func (a *Archive) ARN() string

type Bus

type Bus struct {
	Name string            `json:"name"`
	Tags map[string]string `json:"tags,omitempty"`
}

Bus is a custom event bus.

type InputTransformer

type InputTransformer struct {
	PathsMap map[string]string `json:"paths_map,omitempty"`
	Template string            `json:"template"`
}

InputTransformer maps event paths into a template.

type Options

type Options struct {
	// DataDir holds the bbolt store (eventbridge.bolt). Required.
	DataDir string
	// Peers resolves SQS/Lambda targets. Nil disables delivery (logged).
	Peers peers.Directory
	// Logf receives log lines; nil discards.
	Logf func(format string, args ...any)
	// Clock overrides time.Now in tests.
	Clock func() time.Time
}

Options configures the service.

type Replay added in v0.2.0

type Replay struct {
	Name           string   `json:"name"`
	EventSourceArn string   `json:"archive_arn"` // archive ARN
	DestinationArn string   `json:"dest_arn"`    // bus ARN
	FilterArns     []string `json:"filter_arns,omitempty"`
	EventStartTime int64    `json:"event_start"`
	EventEndTime   int64    `json:"event_end"`
	State          string   `json:"state"`
	StateReason    string   `json:"state_reason,omitempty"`
	StartTime      int64    `json:"start"`
	EndTime        int64    `json:"end"`
	LastEventTime  int64    `json:"last_event"`
}

Replay is a completed (local replays run synchronously) archive replay.

func (*Replay) ARN added in v0.2.0

func (r *Replay) ARN() string

type Rule

type Rule struct {
	Bus      string            `json:"bus"`
	Name     string            `json:"name"`
	Pattern  string            `json:"pattern,omitempty"`  // event pattern JSON
	Schedule string            `json:"schedule,omitempty"` // rate(...) driven by ticker; cron(...) stored only
	State    string            `json:"state"`              // ENABLED | DISABLED
	Desc     string            `json:"desc,omitempty"`
	Targets  []Target          `json:"targets,omitempty"`
	Tags     map[string]string `json:"tags,omitempty"`
}

Rule is one rule on a bus.

func (*Rule) ARN

func (r *Rule) ARN() string

ARN returns the rule ARN.

type Server

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

Server is the EventBridge service: an http.Handler speaking AWS JSON 1.1, and an io.Closer.

func New

func New(opts Options) (*Server, error)

New opens the store under DataDir (the default bus exists implicitly).

func (*Server) Close

func (s *Server) Close() error

Close stops the scheduler, waits for it to exit (so nothing touches the store after this), and closes the bbolt DB. Safe to call more than once.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Store

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

Store is the bbolt-backed EventBridge state.

func (*Store) AppendArchiveEvent added in v0.2.0

func (s *Store) AppendArchiveEvent(name string, t int64, eventJSON []byte) error

AppendArchiveEvent stores one event under an archive and bumps its counters.

func (*Store) CreateArchive added in v0.2.0

func (s *Store) CreateArchive(a Archive) error

CreateArchive registers an archive over an existing bus.

func (*Store) CreateBus

func (s *Store) CreateBus(name string, tags map[string]string) error

CreateBus registers a custom bus.

func (*Store) DeleteArchive added in v0.2.0

func (s *Store) DeleteArchive(name string) error

DeleteArchive removes an archive and its event log.

func (*Store) DeleteBus

func (s *Store) DeleteBus(name string) error

DeleteBus removes a custom bus and its rules.

func (*Store) DeleteRule

func (s *Store) DeleteRule(bus, name string) error

DeleteRule removes a rule (Force semantics: targets go with it).

func (*Store) GetArchive added in v0.2.0

func (s *Store) GetArchive(name string) (*Archive, error)

GetArchive loads one archive.

func (*Store) GetReplay added in v0.2.0

func (s *Store) GetReplay(name string) (*Replay, error)

GetReplay loads one replay.

func (*Store) GetRule

func (s *Store) GetRule(bus, name string) (*Rule, error)

GetRule loads one rule.

func (*Store) ListArchives added in v0.2.0

func (s *Store) ListArchives(namePrefix, sourceArn string) ([]Archive, error)

ListArchives returns archives filtered by name prefix and/or source ARN, sorted.

func (*Store) ListBuses

func (s *Store) ListBuses() ([]Bus, error)

ListBuses returns the default bus plus custom buses, sorted.

func (*Store) ListReplays added in v0.2.0

func (s *Store) ListReplays(namePrefix string) ([]Replay, error)

ListReplays returns replays filtered by name prefix, sorted.

func (*Store) PutReplay added in v0.2.0

func (s *Store) PutReplay(r Replay) error

PutReplay stores a replay record.

func (*Store) PutRule

func (s *Store) PutRule(r Rule) error

PutRule creates or updates a rule.

func (*Store) ReplayEvents added in v0.2.0

func (s *Store) ReplayEvents(name string, start, end int64, fn func(eventJSON []byte)) (int64, int64, error)

ReplayEvents calls fn for each archived event whose ingestion time is within [start, end] (inclusive; a zero bound is open). Returns the count and the latest event time seen.

func (*Store) Rules

func (s *Store) Rules(bus, prefix string) ([]Rule, error)

Rules lists a bus's rules, optionally by name prefix.

func (*Store) UpdateArchive added in v0.2.0

func (s *Store) UpdateArchive(name string, fn func(*Archive) error) error

UpdateArchive applies fn to an archive.

func (*Store) UpdateRule

func (s *Store) UpdateRule(bus, name string, fn func(*Rule) error) error

UpdateRule applies fn to a rule.

type Target

type Target struct {
	ID               string            `json:"id"`
	ARN              string            `json:"arn"`
	Input            string            `json:"input,omitempty"`      // literal input override
	InputPath        string            `json:"input_path,omitempty"` // $.path extraction
	InputTransformer *InputTransformer `json:"input_transformer,omitempty"`
}

Target is one rule target.

Jump to

Keyboard shortcuts

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