Creating Custom Links

How to create custom processing links

Links are the modular processing units of the Conserver. This guide explains how to create your own custom links to extend the system's functionality.

Every link must implement a run function with this signature:

def run(
    vcon_uuid: str,
    link_name: str,
    opts: dict = default_options
) -> str | None:
    """
    Process a vCon through this link.

    Args:
        vcon_uuid: UUID of the vCon to process
        link_name: Name of this link instance in config
        opts: Configuration options merged with defaults

    Returns:
        str: vCon UUID to continue chain (usually same as input)
        None: Stop chain processing for this vCon
    """

Working with vCon Objects

Reading vCon Data

Processing Dialogs

Checking Existing Analysis

Adding Results

Filtering and Routing

Stopping Chain Processing

Return None to stop processing for this vCon:

Routing to Different Queues

External API Integration

With Retry Logic

Metrics and Monitoring

Project Structure

Organize your link as a Python package:

__init__.py

Configuration

Configure your link in config.yml:

Distribution

As a PyPI Package

As a GitHub Repository

Reference directly in config:

Testing

Best Practices

  1. Always merge options with defaults - Ensures your link works even with partial configuration

  2. Check if processing already done - Avoid reprocessing if analysis already exists

  3. Use structured logging - Include vCon UUID and link name in all log messages

  4. Handle errors appropriately - Raise exceptions to send vCons to DLQ, or return UUID to continue

  5. Add metrics - Track processing time, success/failure rates

  6. Document your options - Make it clear what configuration your link accepts

  7. Test thoroughly - Unit test your processing logic

  8. Be idempotent - Running twice should produce the same result

Last updated

Was this helpful?