eventbridge

package module
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

README

AWS EventBridge Broker

The sub-module implements swarm broker for AWS EventBridge. See the library documentation for details.

Serverless

AWS Event Bridge has a feature that allows to match execution of consumer to the pattern of JSON object. Use it to build reliable matching of incoming events:

/*
enq <- &swarm.Event[User]{
  Meta: &swarm.Meta{Agent: "swarm:example", Participant: "user"},
  Data: &User{ID: "user", Text: "some text"},
}
*/

stack.NewSink(
  &eventbridge.SinkProps{
    EventPattern: eventbridge.Event(
      eventbridge.Type[User](),
      eventbridge.Meta("agent", curie.IRI("swarm:example"))
      eventbridge.Meta("participant", curie.IRI("user"))
    ),
    /* ... */
  },
)

Limitation

AWS EventBridge cannot transmit bytes. They have to be enveloped as JSON object. The library implements automatic encapsulation using built-in kernel/encoding/CodecPacket. Use these codec (WithPacketCodec) if you automatically source events from EventBridge to SQS.

Documentation

Index

Constants

View Source
const EnvConfigSourceEventBridge = "CONFIG_SWARM_SOURCE_EVENTBRIDGE"

Environment variable to config event source

View Source
const Version = "broker/eventbridge/v0.21.0"

Variables

This section is empty.

Functions

func Like added in v0.21.0

func Like(seq ...Expr) *awsevents.EventPattern

Like combinator defines DSL to configure awsevents.EventPattern https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-pattern.html

func New

func New(bus string, opts ...Option) (*kernel.Kernel, error)

Create enqueue & dequeue routine to AWS EventBridge

func NewDequeuer added in v0.20.1

func NewDequeuer(bus string, opts ...Option) (*kernel.Dequeuer, error)

Create reader from AWS EventBridge

func NewEnqueuer added in v0.20.1

func NewEnqueuer(bus string, opts ...Option) (*kernel.Enqueuer, error)

Create writer to AWS EventBridge

Types

type Broker

type Broker struct {
	constructs.Construct
	Bus awsevents.IEventBus
	// contains filtered or unexported fields
}

func NewBroker

func NewBroker(scope constructs.Construct, id *string, props *BrokerProps) *Broker

func (*Broker) AddEventBus

func (broker *Broker) AddEventBus(eventBusName string) awsevents.IEventBus

func (*Broker) NewEventBus

func (broker *Broker) NewEventBus(props *awsevents.EventBusProps) awsevents.IEventBus

func (*Broker) NewSink

func (broker *Broker) NewSink(props *SinkProps) *Sink

type BrokerProps

type BrokerProps struct {
	System string
}

type Client

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

EventBridge client

func (*Client) Enq

func (cli *Client) Enq(ctx context.Context, bag swarm.Bag) error

Enq enqueues message to broker

type EventBridge

type EventBridge interface {
	PutEvents(context.Context, *eventbridge.PutEventsInput, ...func(*eventbridge.Options)) (*eventbridge.PutEventsOutput, error)
}

EventBridge declares the subset of interface from AWS SDK used by the lib.

type Expr added in v0.21.0

type Expr func(*awsevents.EventPattern)

Event Pattern expression

func Category added in v0.21.0

func Category(cats ...string) Expr

Configure event pattern to match a category

func EventData added in v0.21.0

func EventData(key string, values ...any) Expr

Configure event pattern to match Event's Data key

func EventMeta added in v0.21.0

func EventMeta(key string, values ...any) Expr

Configure event pattern to match Event's Meta key

func Has added in v0.21.0

func Has(key string, values ...any) Expr

Configure event pattern to match object's key

func Source added in v0.21.0

func Source(sources ...string) Expr

Configure event pattern to match source(s)

func Type added in v0.21.0

func Type[T any]() Expr

Configure event pattern to match a type

type Option added in v0.20.0

type Option func(*Client)

func WithConfig added in v0.20.0

func WithConfig(opts ...swarm.Option) Option

func WithService added in v0.20.0

func WithService(service EventBridge) Option

type Sink

type Sink struct {
	constructs.Construct
	Rule    awsevents.Rule
	Handler awslambda.IFunction
}

func NewSink

func NewSink(scope constructs.Construct, id *string, props *SinkProps) *Sink

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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