Skip to main content
The Connector Platform is the subsystem responsible for bridging external communication platforms (e.g., Discord, Slack) with the Palyra daemon. It provides a unified API for managing connector lifecycles, processing inbound messages through a structured pipeline, and draining outbound message queues with built-in retry logic and dead-letter handling.

ChannelPlatform and ConnectorSupervisor

The ChannelPlatform serves as the high-level coordinator within the daemon crates/palyra-daemon/src/channels.rs#106-110. It encapsulates the ConnectorSupervisor, which manages the lifecycle of individual ConnectorAdapter instances.

Key Components

ComponentResponsibility
ChannelPlatformOrchestrates initialization, default inventory, and provides the public API for the daemon crates/palyra-daemon/src/channels.rs#106-110.
ConnectorSupervisorManages the runtime state, registration, and status of all connectors crates/palyra-connectors/src/lib.rs#2-12.
ConnectorStoreA SQLite-backed store for persisting connector configurations, instance records, and outbox messages crates/palyra-daemon/src/channels.rs#119-119.
ConnectorAdapterA trait implemented by specific platform integrations (e.g., DiscordConnectorAdapter) to handle low-level transport crates/palyra-connectors/src/connectors/mod.rs#16-18.

Initialization Lifecycle

When ChannelPlatform::initialize is called, it performs the following steps:
  1. Opens the ConnectorStore at the specified path crates/palyra-daemon/src/channels.rs#119-119.
  2. Initializes the MediaArtifactStore for handling message attachments crates/palyra-daemon/src/channels.rs#120-124.
  3. Creates a GrpcChannelRouter to bridge inbound connector events back to the daemon’s gRPC services crates/palyra-daemon/src/channels.rs#125-126.
  4. Instantiates the ConnectorSupervisor with a set of default_adapters (Echo and Discord) crates/palyra-daemon/src/channels.rs#127-132.
Sources: crates/palyra-daemon/src/channels.rs#106-140, crates/palyra-connectors/src/connectors/mod.rs#16-18

Inbound Message Pipeline

Inbound messages flow from the external platform through the adapter into the ConnectorSupervisor, which then routes them to the daemon via the GrpcChannelRouter.

Data Flow: Inbound Message

  1. Ingestion: The ConnectorAdapter receives a message and emits an InboundMessageEvent.
  2. Preprocessing: Attachments are preprocessed and stored in the MediaArtifactStore crates/palyra-daemon/src/channels.rs#125-126.
  3. Routing: The GrpcChannelRouter constructs a RouteMessageRequest crates/palyra-daemon/src/channels.rs#32-33.
  4. Daemon Entry: The message is submitted to the Gateway’s gRPC endpoint using HEADER_CHANNEL and HEADER_PRINCIPAL for authentication crates/palyra-daemon/src/channels.rs#31-31.

Code Entity Mapping: Inbound Routing

The following diagram shows how inbound messages are transformed from raw events into routed requests. Title: Inbound Routing Pipeline Sources: crates/palyra-daemon/src/channels.rs#125-132, crates/palyra-daemon/src/channel_router.rs#215-227, crates/palyra-daemon/src/transport/grpc/auth.rs#31-31

Outbound Message Pipeline

Outbound messages are enqueued in the ConnectorStore outbox and processed by a background “drain” loop.

Outbound Drain Logic

The ConnectorSupervisor periodically drains the outbox for each active connector.
  1. Selection: It fetches OutboxEntryRecord items that are pending or scheduled for retry.
  2. Dispatch: It calls ConnectorAdapter::send_outbound crates/palyra-connectors/src/connectors/echo.rs#43-47.
  3. Outcome Handling:

Code Entity Mapping: Outbound Pipeline

The following diagram illustrates the lifecycle of an outbound message from enqueue to delivery. Title: Outbound Drain and Retry Lifecycle Sources: crates/palyra-connectors/src/connectors/echo.rs#43-75, crates/palyra-connectors/src/lib.rs#8-12

Echo Connector

The EchoConnectorAdapter is a specialized implementation used for internal testing and validation of the pipeline crates/palyra-connectors/src/connectors/echo.rs#21-24. Sources: crates/palyra-connectors/src/connectors/echo.rs#18-86

Supported Connectors

The platform defines several connector kinds, though implementation status varies:
Connector KindAvailabilityStatus
EchoInternalTestOnlyFully functional for tests crates/palyra-connectors/src/connectors/echo.rs#35-41.
DiscordSupportedPrimary production connector crates/palyra-connectors/src/connectors/mod.rs#38-38.
SlackDeferredRoadmap item; returns PermanentFailure crates/palyra-connectors/src/connectors/slack.rs#14-30.
TelegramDeferredRoadmap item; returns PermanentFailure crates/palyra-connectors/src/connectors/telegram.rs#14-30.
Sources: crates/palyra-connectors/src/connectors/mod.rs#1-18, crates/palyra-connectors/src/connectors/slack.rs#1-31, crates/palyra-connectors/src/connectors/telegram.rs#1-31