Skip to main content
The Connector Framework provides a standardized abstraction for the Palyra daemon to interact with external messaging platforms (Discord, Slack, etc.). It manages the lifecycle of connector instances, ensures delivery idempotency, handles message queuing with SQLite persistence, and implements sophisticated retry logic through a centralized supervisor.

ConnectorAdapter Trait

The ConnectorAdapter trait is the core interface that every platform integration must implement. It abstracts away platform-specific APIs into a set of standard asynchronous operations.
FunctionDescription
kind()Returns the ConnectorKind (e.g., Discord, Echo, Slack) crates/palyra-connector-core/src/supervisor.rs#138-138.
availability()Indicates if the connector is Supported, InternalTestOnly, or Deferred crates/palyra-connector-core/src/supervisor.rs#140-140.
send_outbound()The primary method for delivering messages to the external platform crates/palyra-connector-core/src/supervisor.rs#169-173.
poll_inbound()Optional method for connectors that use polling instead of WebSockets/Webhooks crates/palyra-connector-core/src/supervisor.rs#161-167.
runtime_snapshot()Returns platform-specific health and state data as JSON crates/palyra-connector-core/src/supervisor.rs#154-159.

Data Flow: Outbound Message Path

Outbound messages follow a rigorous path through the supervisor and store to ensure they are never lost and are delivered exactly once where possible. Connector Outbound Pipeline Sources: crates/palyra-connector-core/src/supervisor.rs#194-214, crates/palyra-connector-core/src/supervisor.rs#431-443

ConnectorSupervisor

The ConnectorSupervisor acts as the orchestrator for all active connectors. It maintains a registry of available ConnectorAdapter implementations and manages the background tasks for draining the outbox and polling for inbound events. Key responsibilities: Sources: crates/palyra-connector-core/src/supervisor.rs#194-214, crates/palyra-daemon/src/transport/http/handlers/admin/channels/mod.rs#29-53

ConnectorStore (SQLite Persistence)

All connector state is backed by a SQLite database through the ConnectorStore. This provides durability for messages and prevents loss during daemon restarts.

Schema Entities

EntityDescription
ConnectorInstanceRecordStores configuration, credentials (vault refs), and liveness state for a connector crates/palyra-connector-core/src/storage.rs#4-4.
OutboxEntryRecordRepresents a message waiting for delivery. Includes envelope_id for idempotency crates/palyra-connector-core/src/storage.rs#20-21.
DeadLetterRecordStores messages that failed permanently or exceeded max retries, including the failure reason crates/palyra-connector-core/src/storage.rs#8-8.
Sources: crates/palyra-connector-core/src/storage.rs#1-21, crates/palyra-connector-core/src/supervisor.rs#195-195

Delivery Idempotency and Retries

The framework uses an envelope_id to ensure that even if a network request is retried, the external platform does not create duplicate messages.

RetryClass and Backoff

When send_outbound fails, the adapter returns a RetryClass which determines the supervisor’s next action: Code to Entity Mapping Sources: crates/palyra-connectors/src/connectors/mod.rs#15-18, crates/palyra-connector-core/src/supervisor.rs#194-199

EchoConnectorAdapter

The EchoConnectorAdapter is a specialized implementation used for testing and internal diagnostics. It simulates delivery by storing “sent” messages in an in-memory map and supports a special marker [connector-crash-once] to test the supervisor’s retry logic. Sources: crates/palyra-connectors/src/connectors/echo.rs#21-76

Webhook Management

The daemon includes a WebhookRegistry for managing inbound HTTP callbacks from external services. Sources: crates/palyra-daemon/src/webhooks.rs#107-118, crates/palyra-cli/src/commands/webhooks.rs#17-31