Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Relay API

Functions for managing relay pipeline configurations. All live in the tide schema.


tide.relay_set_outbox

Configure a forward relay pipeline (outbox → external sink).

SELECT tide.relay_set_outbox(
  p_name        TEXT,
  p_outbox      TEXT,
  p_sink        TEXT,
  p_config      JSONB    DEFAULT '{}'::jsonb,
  p_batch_size  INT      DEFAULT 100,
  p_enabled     BOOLEAN  DEFAULT true
);
ParameterTypeDefaultDescription
p_nameTEXT(required)Unique pipeline name
p_outboxTEXT(required)Source outbox name
p_sinkTEXT(required)Sink type: nats, kafka, redis, rabbitmq, sqs, webhook, stdout
p_configJSONB{}Sink-specific configuration
p_batch_sizeINT100Messages per relay batch
p_enabledBOOLEANtrueWhether the pipeline is active

Upsert behavior: If a pipeline with the same name exists, its configuration is updated.

Example:

SELECT tide.relay_set_outbox('orders-to-nats', 'orders', 'nats',
  jsonb_build_object(
    'url', 'nats://localhost:4222',
    'subject', 'orders.{event_type}'
  ),
  p_batch_size := 200
);

tide.relay_set_inbox

Configure a reverse relay pipeline (external source → inbox).

SELECT tide.relay_set_inbox(
  p_name         TEXT,
  p_inbox        TEXT,
  p_config       JSONB    DEFAULT '{}'::jsonb,
  p_batch_size   INT      DEFAULT 100,
  p_source       TEXT     DEFAULT 'stdout',
  p_enabled      BOOLEAN  DEFAULT true,
  p_max_retries  INT      DEFAULT 3,
  p_idempotent   BOOLEAN  DEFAULT true
);
ParameterTypeDefaultDescription
p_nameTEXT(required)Unique pipeline name
p_inboxTEXT(required)Target inbox name
p_configJSONB{}Source-specific configuration
p_batch_sizeINT100Messages per batch
p_sourceTEXT'stdout'Source type: nats, kafka, redis, rabbitmq, sqs, webhook, stdin
p_enabledBOOLEANtrueWhether the pipeline is active
p_max_retriesINT3Max delivery retries
p_idempotentBOOLEANtrueUse inbox dedup (recommended)

tide.relay_enable

Enable a previously disabled pipeline.

SELECT tide.relay_enable(p_name TEXT);

Fires pg_notify('tide_relay_config', name) to trigger hot-reload in the relay.


tide.relay_disable

Disable a pipeline (stops processing without deleting config).

SELECT tide.relay_disable(p_name TEXT);

tide.relay_delete

Permanently delete a pipeline configuration.

SELECT tide.relay_delete(p_name TEXT);

tide.relay_get_config

Retrieve the full configuration for a pipeline.

SELECT tide.relay_get_config(p_name TEXT) → JSONB

Returns the stored config JSONB for the named pipeline.


tide.relay_list_configs

List all configured relay pipelines.

SELECT tide.relay_list_configs() → JSONB

Returns a JSON array of all pipelines with their direction and enabled status:

[
  {"name": "orders-to-nats", "direction": "outbox", "enabled": true},
  {"name": "webhooks-in", "direction": "inbox", "enabled": true}
]