The first version of tobox (v0.7.0) has been released.
tobox implements the consumer side of the transactional outbox pattern,
providing a simple way to configure your event handlers.
* OS / tobox · GitLab
* Pattern: Transactional outbox
tobox executes your handlers in a worker pool. The worker pool can be
thread-based (default) or fiber-based.
It uses the “SKIP LOCKED” SQL dialect to support concurrent polling for
events from the database outbox table. It therefore only supports databases
implementing it. As of today, that's:
* PostgreSQL 9.5+
* MySQL 8+
* Oracle
* Microsoft SQL Server
It ships with plugins for sentry, datadog and zeitwerk. The plugin system
is itself very simple, so you can add your own custom logic around event
processing.
It can be used as a background job processor, although it’s best used in
tandem with an existing framework.
Here are the updates since the last release:
## [0.7.0] - 2024-12-18
### Features
#### `:pg_notify` plugin
The `:pg_notify` plugin is introduced, which leverages the PostgreSQL-only
`LISTEN/NOTIFY` statements to asynchronously notify workers when there are
new events to be processed (instead of regularly polling the database).
#### `visibility_column` and `attempts_column` configuration
The `visibility_column` configuration (default: `:run_at`) can be used not
only to point to a differently named column, it can both point to either a
timestamp column (used as a visibility timeout for events) or a boolean
column (used to hide events from other transactions); using the latter will
also disable exponential backoff in retries.
The `attempts_column` configuration (default: `:attempts`) can be used to
point to a differently named column, or, when set to `nil`, uncap retries.
See when they can be used for in the readme recommendations section.
### Improvements
#### fiber pool on async
Support was removed for the `fiber_scheduler` gem, which is
under-maintained, so the fiber worker pool will use an [async](
GitHub - socketry/async: An awesome asynchronous event-driven reactor for Ruby.) scheduler going forward. Functionality
and APIs will be the same, but you'll have to add it to your Gemfile.
### Bugfixes
* `datadog` integration: environment variables were wrongly named.
### Chore
* `mutex_m` usage was removed.
## [0.6.1] - 2024-10-30
### Improvements
When possible, use `UPDATE FROM outbox RETURNING WHERE (SELECT id .... FOR
UPDATE SKIP LOCKED` to fetch-and-update events in one go.
## [0.6.0] - 2024-10-25
### Features
#### Batch Events handling
It's now possible to handle N events at a time.
# tobox.rb
batch_size 10 # fetching 10 events at a time
on("user_created", "user_updated") do |*events| # 10 events at most
if events.size == 1
DataLakeService.user_created(events.first)
else
DataLakeService.batch_users_created(events)
end
end
This also supports raising errors only for a subset of the events which
failed processing (more info in the README).
## [0.5.2] - 2024-10-22
## Bugfixes
* prevent `:max_connections` from being overidden.
### Improvements
## [0.5.1] - 2024-09-26
### Improvements
* Refactoring of management of event id which replaces `SELECT id IN (?)`
resulting queries with `SELECT id = ?`.
* Process shutdown is now more predictable, also in the grace period.
* `grace_shutdown_timeout` is a new configuration, by default 5 (seconds).