When you create a routing function, you define an Elixir function that returns routing information. Sequin will use this information to determine the destination for each message.For each message, your routing function receives the same parameters as a transform function and must return a map containing the sink-specific routing information:
def route(action, record, changes, metadata) do # Return a map with sink-specific routing parameters %{ # Sink-specific routing parameters }end
In general, some details of how the message is processed will be static and fixed by the sink. Routing functions enable you to customize the behavior of a sink, but they are not intended to replace the idea of multiple sinks where necessary.
For example, for the HTTP Webhook sink, the base URL is a static property - this improves batching and enables other performance optimizations such as connection pooling and request pipelining.
For HTTP webhooks, your routing function must return a map with these keys:
Key
Type
Description
Example
method
String
The HTTP method to use
"POST", "PUT", "DELETE"
endpoint_path
String
The path to append to your webhook base URL
"/users/123"
The endpoint_path you specify will be appended to the base URL of your webhook endpoint. For example, if your webhook endpoint is https://api.example.com and your routing function returns endpoint_path: "/users/123", the message will be sent to https://api.example.com/users/123.
When creating or editing a routing function, you can test it with real data from your database. Sequin will capture recent events and show you the effective routing parameters for each message.“Effective” means that Sequin will show the routing parameters that will actually be used downstream, inclusive of any defaulting or validation which happens after your routing function runs.