## [Unreleased] ## [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. ```ruby # 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). ## [0.5.0] - 2024-09-16 ### Features A new `:progress` plugin can be used in order to release database transactions before handling events (useful for when event handling times vary and may cause transaction bookkeeping overhead in the database). **Note**: This may become the default behaviour in a future release. ### Improvements * The event grouping and inbox capabilities were converted into plugins (respectively, `:event_grouping` and `:inbox`). ### Bugfixes * exponential backoff calculation was broken. * behaviour fixed for databases which do not support `ON CONFLICT` or `UPDATE ... RETURNING` (like MySQL). ## [0.4.5] - 2024-02-28 ### Bugfixes Fixed latest barrage of `ddtrace` discontinued config APIs, which is still happening under minor releases. ## [0.4.4] - 2023-07-26 ### Improvements A new option, `database_options`, is now supported. The resulting hash is passed to ´Sequel.connect` on database initialization. ## [0.4.3] - 2023-06-01 ### Bugfixes The `sentry` plugin didn't load correctly: given that app code loads before the `tobox` config, it means that, if app code runs `Sentry.init`, then the `tobox` config won't be able to fiddle anymore with it. This fixes it by making the Sentry.init call a part of the `sentry` plugin. This means that `tobox` config now includes a new callback: ```ruby plugin(:sentry) on_sentry_init do |sentry_cfg| sentry_cfg.dsn = ... ``` ### Improvements ## [0.4.2] - 2023-05-25 ### Improvements `stats` plugin: use `max_connections = 1` instead of enabling single threaded mode for the dedicated `sequel` database object. The single threaded mode is not compliant with some `sequel` plugins and extensions, most notable the `:connection_validator` plugin. ## [0.4.1] - 2023-05-24 ### Features #### `on_database_connect` this adds an extension point for internal sequel database objects, in cases where some tweaks are required (such as in the case of, when using database SSL proxies, setting connection validators). ```ruby # tobox.rb on_database_connect do |db| db.extension(:connection_validator) end ``` ## [0.4.0] - 2023-05-19 ### Features #### `:stats` plugin The `:stats` plugin collects statistics related with the outbox table periodically, and exposes them to app code (which can then relay them to a statsD collector, or similar tool). ```ruby plugin(:stats) on_stats(5) do |stats_collector| # every 5 seconds stats = stats_collector.collect StatsD.gauge('outbox_pending_backlog', stats[:pending_count]) end ``` Read more about it in [the project README](https://gitlab.com/os85/tobox#stats). #### on_start/on_stop callbacks The `on_start` and `on_stop` callbacks can now be defined in `tobox` configuration: ```ruby # tobox.rb on_start do puts "tobox is starting..." end on_stop do puts "tobox is stopping..." end ``` ### Bugfixes * tobox configuration file is now only loaded after everything else, so access to application code is guaranteed. ## [0.3.2] - 2023-03-06 ### Bugfixes * allow sentry error capture if `report_after_retries` option is turned off. ## [0.3.1] - 2023-03-03 ### Bugfixes In Sentry plugin, exception capturing is no longer dependent on transaction monitoring being enabled (if `traces_sampling_rate` would be set to 0, exceptions wouldn't be capture; now they are). ## [0.3.0] - 2022-12-12 ### Features #### Inbox Implementation of the "inbox pattern", which ensures that events are processed to completion only once. ```ruby # create an inbox table and reference it create_table(:inbox) do column :id, :varchar, null: true, primary_key: true # ... create_table(:outbox) do column :inbox_id, :varchar foreign_key :inbox_id, :inbox # ... # tobox.rb inbox_table :inbox inbox_column :inbox_id # event production DB[:outbox].insert(event_type: "order_created", inbox_id: "order_created_#{order.id}", .... DB[:outbox].insert(event_type: "billing_event_started", inbox_id: "billing_event_started_#{order.id}", .... ``` ## [0.2.0] - 2022-12-05 ### Features #### Ordered event processing When the outbox table contains a `:group_id` table (and the producer fills up events with it), then a group of events with the same `:group_id` will be processed one by one, by order of insertion. ```ruby # migration create_table(:outbox) do column :message_group_id, :integer # tobox.rb message_group_column :group_id # event production DB[:outbox].insert(event_type: "order_created", message_group_id: order.id, .... DB[:outbox].insert(event_type: "billing_event_started", message_group_id: order.id, .... # order_created handled first, billing_event_started only after ``` #### on_error_worker callback The config option `on_error_worker { |error| }` gets called when an error happens in a worker **before** events are processed (p.ex. when the database connection becomes unhealthy). You can use it to report such errors to an error reporting system (the `sentry` plugin relies on it). ```ruby # tobox.rb on_error_worker { |error| Sentry.capture_exception(error, hint: { background: false }) } ``` ### Bugfixes Thread workers: when errors happen which bring down the workers (such as database becoming unresponsive), workers will be restarted. ## [0.1.6] - 2022-10-06 ### Bugfixes Allow passing datadog options, initialize tracing from plugin. ## [0.1.5] - 2022-10-06 ### Bugfixes Fixing datadog plugin name. ## [0.1.4] - 2022-10-06 ### Bugfixes Actual fix for missing datadog constants. ## [0.1.3] - 2022-10-06 ### Bugfixes Datadog constants unproperly namespaced. ## [0.1.2] - 2022-09-14 ### Bugfixes Actual fix for foregoing json parsing. ## [0.1.1] - 2022-09-14 ### Chore Improved default logger, by logging the thread name, as well as providing the worker id in the lifecycle event logs. ### Bugfixes Do not try to json parse already parsed json columns (this happens if the DB object already has `:pg_json` extension loaded). ## [0.1.0] - 2022-09-05 - Initial release. * `tobox` entrypoint to start the consumer. * `sentry` integration. * `datadog` integration. * `zeitwerk` integration.