Mailer
SDK

Errors and Observability

Failure policies, backpressure metrics, and the dashboard.

Process errors

Use Process when a transform can fail.

stream.Process(fn,
    operator.WithProcessFailurePolicy(operator.ProcFailureDLQ),
    operator.WithProcessDLQ(dlqSink),
)

Use Fail policies for data that must not be skipped. Use DLQ policies when bad records should be retained for later inspection.

Sink errors

Kafka and Postgres sinks support retry and failure policy options. After retries are exhausted, the configured policy decides whether the record is dropped, sent to DLQ, or fails the pipeline.

Backpressure

Mailer uses bounded channels between execution stages. If a sink is slow, its input edge fills. The previous stage blocks while sending, and that pressure propagates back to the source. This bounds memory without dropping records.

Tune the edge capacity with:

env := mailer.NewEnv().WithBufferSize(2048)

Metrics

Mailer records Prometheus metrics for pipeline, stages, edges, operators, and workers.

Important metrics:

MetricMeaning
mailer_edge_queue_sizeCurrent buffered records on an edge.
mailer_edge_queue_capacityEdge capacity.
mailer_stage_records_in_totalRecords entering a stage.
mailer_stage_records_out_totalRecords leaving a stage.
mailer_stage_send_block_seconds_totalTime blocked on downstream backpressure.
mailer_stage_workersActive worker count for a stage.
mailer_stage_errors_totalStage errors.

Dashboard

The dashboard package exposes pipeline structure and metrics for live inspection. Labels passed to SDK operators are used in dashboard metadata:

stream.Filter(isCompleted, "completed-orders")

On this page