Experimental feature of RES ecosystem.
This repository includes a process and a Rails Event Store scheduler, which can be used to transactionally enqueue background jobs into your background jobs tool of choice. The scheduler included in this repo adds the jobs into the RDBMS into specific table instead of redis inside your transaction, and the process is enqueuing the jobs from that table to the background jobs tool.
Add to your gemfile in application:
gem "ruby_event_store-outbox"
Generate and execute the migration adding necessary tables. If it's needed, change the type of the payload
column to mediumbinary
or longbinary
.
bin/rails generate ruby_event_store:outbox:migration
In your event store configuration, as a dispatcher use RubyEventStore::ImmediateAsyncDispatcher
with RubyEventStore::Outbox::SidekiqScheduler
, for example:
RailsEventStore::Client.new(
dispatcher: RailsEventStore::ImmediateAsyncDispatcher.new(scheduler: RubyEventStore::Outbox::SidekiqScheduler.new),
...
)
Additionally, your handler's through_outbox?
method should return true
, for example:
class SomeHandler
def self.through_outbox?
true
end
end
Run following process in any way you prefer:
res_outbox \
--database-url="mysql2://[email protected]:3306/my_database" \
--redis-url="redis://localhost:6379/0" \
--log-level=info \
--split-keys=sidekiq_queue1,sidekiq_queue2
It is possible to run as many instances as you prefer, but it does not make sense to run more instances than there are different split keys (sidekiq queues), as one process is operating at one moment only one split key.
It is possible for the outbox process to send metrics to InfluxDB (this requires influxdb gem in version at least 0.8.1). In order to do that, specify a --metrics-url
parameter, for example:
res_outbox --database-url="mysql2://[email protected]:3306/my_database" \
--redis-url="redis://localhost:6379/0" \
--log-level=info \
--split-keys=sidekiq_queue1,sidekiq_queue2 \
--metrics-url=http://user:password@localhost:8086/dbname"
Bug reports and pull requests are welcome on GitHub at https://github.com/RailsEventStore/rails_event_store.
- Bump version
make build
make push
make docker-build
make docker-push