iii

Event

Event bus for pub/sub messaging.

An event bus for publish-subscribe messaging patterns.

modules::event::EventModule

Sample Configuration

- class: modules::event::EventModule
  config:
    adapter:
      class: modules::event::adapters::RedisAdapter
      config:
        redis_url: ${REDIS_URL:redis://localhost:6379}

Configuration

adapter
Adapter

The adapter to use for event persistence and distribution. The Redis adapter is recommended for production use.

Adapters

modules::event::adapters::RedisAdapter

Uses Redis Pub/Sub to handle event distribution across workers. This adapter ensures reliable message delivery in distributed environments.

class: modules::event::adapters::RedisAdapter
config:
  redis_url: ${REDIS_URL:redis://localhost:6379}

Configuration

redis_url
string

The URL of the Redis instance to use for event distribution.

Functions

event.emit
function

Publishes an event to a specific topic.

Trigger Type

This Module adds a new Trigger Type: event.

Sample Code

// Register a function to handle events
bridge.registerFunction({
  function_path: 'events.onUserCreated',
  handler: async (data) => {
    console.log('User created:', data)
    // Process the event
  },
})

// Subscribe to the 'user.created' topic
bridge.registerTrigger({
  trigger_type: 'event',
  function_path: 'events.onUserCreated',
  config: {
    subscribes: ['user.created'],
  },
})

// Emit an event
await bridge.invokeFunction({
  function_path: 'event.emit',
  data: {
    topic: 'user.created',
    data: { id: '123', email: 'user@example.com' },
  },
})

Event Flow

On this page