When generating a new Sequent project the configuration can be found in
You are free to determine your own location as long as you require the file at startup of your application.
There are many configuration options, but mostly you can stick to the defaults. With that thought in mind this chapter is divided into 3 sections:
- The minimum configuration you need
- Configuration options you will likely want to change
- The complete overview of options. Basically the rest.
As a bare minimum you need:
require './db/migrations' Sequent.configure do |config| config.migrations_class_name = 'Migrations' config.command_handlers = [ YourCommandHandler.new, OtherCommandHandler.new, ] config.event_handlers = [ MyProjector.new, MyWorkflow.new, ] end
migration_class_name is the name of the class used to define your Migrations. See the Migrations chapter for an in-depth explanation.
Frequently used configuration:
Sequent.configure do |config| # minimum config omitted # common config options config.command_filters = [ MyFilter.new, ] config.number_of_replay_processes = 4 config.logger = Logger.new(STDOUT) end
CommandFilters can be used to enforce certain criteria are met before executing commands. Typical
concerns are authorization in a user based application. A filter must implement the method
If any of the CommandFilters raises an Exception then execution is aborted for all passed Commands.
class AdminFilter def execute(command) fail NotAnAdmin unless is_allowed?(command.user_id, command.class) end # only admin may execute admin commands def is_allowed?(user_id, command_class) return false if !UserRecord.is_admin?(user_id) && command_class <= AdminCommand return true end end Sequent.configure do |config| config.command_filters = [ AdminFilter.new, ] end
The number of processes used to replay the events when doing a Migration. By default this is 4. This should be adjusted to the capactiy of your server running the Migration.
The ruby Logger used by Sequent.
For the most recent possibilities please check the
|event_record_class||The class mapped to the
|stream_record_class||The class mapped to the
|snapshot_event_class||The event class marking something as a Snapshot event||
|transaction_provider||The transaction provider used by the CommandService||
|event_publisher||The EventPublisher used by the EventStore.||
|command_handlers||The list of CommandHandlers||Empty|
|command_filters||The list of CommandFilters||Empty|
|event_handlers||The list of Projectors and Workflows||Empty|
|uuid_generator||The AggregateRepository. Mainly useful for testing||
|migration_sql_files_directory||The location of the sql files for Migrations||
|view_schema_name||The name of the view_schema in which the projections are created.||
|offline_replay_persistor_class||The class used to persist the the
|online_replay_persistor_class||The class used to persist the the
|number_of_replay_processes||The number of process used while offline migration||
|database_config_directory||The directory in which db config can be found||
|event_store_schema_name||The name of the db schema in which the EventStore is installed||
|migrations_class_name||The name of the class containing the migrations||Empty|
|versions_table_name||The name of the table in which Sequent checks which migration version is currently active||
|replayed_ids_table_name||The name of the table in which Sequent keeps track of which events are already replayed during a migration||