Postboy Help

Registrator

A Registrator is a helper object that manages the lifecycle of message bus registrations in a structured way.

In Postboy, it is used to group related registrations together and make sure they can later be cleaned up correctly. This is especially useful when an application has many messages, subscriptions, executors, or namespaces that should be created and removed as a unit.

What a Registrator is for

Registrators help you:

  • group related registrations in one place

  • keep setup logic separate from business logic

  • manage startup and teardown consistently

  • avoid leaving stale subscriptions or message bindings behind

Why it matters

In event-driven systems, the biggest problems often appear not when something is registered, but when it is not removed correctly.

If subscriptions, handlers, or message bindings remain active after they are no longer needed, the result can be:

  • memory leaks

  • duplicate reactions

  • unexpected message handling

  • hard-to-debug application state

Registrators help prevent that by keeping registration and cleanup paired together.

How Registrators work in Postboy

A Registrator usually performs two main tasks:

  1. registration — connecting messages, executors or handlers to the bus

  2. cleanup — disconnecting and disposing everything that was registered

This makes the lifecycle of communication flows much more predictable.

Key characteristics

A good Registrator in Postboy is typically:

  • structured — it collects related setup operations together

  • lifecycle-aware — it supports both initialization and teardown

  • safe — it helps avoid accidental leftover bindings

  • composable — it can manage multiple related services or flows

When to use a Registrator

Use a Registrator when:

  • your module needs to register several messages or executors at once

  • you want a clean start/stop lifecycle for a feature

  • you are building a larger application with dynamic message wiring

  • you want to make cleanup explicit and reliable

Registrator vs manual registration

Manual registration can work for small cases, but it becomes risky as the system grows.

A Registrator gives you a single place where you can see:

  • what was registered

  • when it was registered

  • how it gets removed

That makes the system easier to maintain and much less likely to accumulate hidden subscriptions.

In short

Registrator is Postboy’s lifecycle helper for bus configuration.
It helps manage registration and cleanup together, reducing leaks, accidental leftovers, and architectural chaos.

24 апреля 2026