Class: OnlineMigrations::BackgroundMigrations::Config
- Inherits:
-
Object
- Object
- OnlineMigrations::BackgroundMigrations::Config
- Defined in:
- lib/online_migrations/background_migrations/config.rb
Overview
Class representing configuration options for background migrations.
Instance Attribute Summary collapse
-
#backtrace_cleaner ⇒ ActiveSupport::BacktraceCleaner?
The Active Support backtrace cleaner that will be used to clean the backtrace of a migration job that errors.
-
#batch_max_attempts ⇒ Integer
Maximum number of batch run attempts.
-
#batch_pause ⇒ Integer
The pause interval between each background migration job's execution (in seconds).
-
#batch_size ⇒ Integer
The number of rows to process in a single background migration run.
-
#error_handler ⇒ Proc
The callback to perform when an error occurs in the migration job.
-
#migrations_module ⇒ String
The module in which background migrations will be placed.
-
#migrations_path ⇒ String
The path where generated background migrations will be placed.
-
#stuck_jobs_timeout ⇒ Integer
The number of seconds that must pass before the running job is considered stuck.
-
#sub_batch_pause_ms ⇒ Integer
The number of milliseconds to sleep between each sub_batch execution.
-
#sub_batch_size ⇒ Integer
The smaller batches size that the batches will be divided into.
-
#throttler ⇒ Proc
Allows to throttle background migrations based on external signal (e.g. database health).
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/online_migrations/background_migrations/config.rb', line 81 def initialize @migrations_path = "lib" @migrations_module = "OnlineMigrations::BackgroundMigrations" @batch_size = 20_000 @sub_batch_size = 1000 @batch_pause = 0.seconds @sub_batch_pause_ms = 100 @batch_max_attempts = 5 @throttler = -> { false } @stuck_jobs_timeout = 1.hour @error_handler = ->(error, errored_job) {} end |
Instance Attribute Details
#backtrace_cleaner ⇒ ActiveSupport::BacktraceCleaner?
The Active Support backtrace cleaner that will be used to clean the backtrace of a migration job that errors.
66 67 68 |
# File 'lib/online_migrations/background_migrations/config.rb', line 66 def backtrace_cleaner @backtrace_cleaner end |
#batch_max_attempts ⇒ Integer
Maximum number of batch run attempts
When attempts are exhausted, the individual batch is marked as failed.
40 41 42 |
# File 'lib/online_migrations/background_migrations/config.rb', line 40 def batch_max_attempts @batch_max_attempts end |
#batch_pause ⇒ Integer
The pause interval between each background migration job's execution (in seconds)
28 29 30 |
# File 'lib/online_migrations/background_migrations/config.rb', line 28 def batch_pause @batch_pause end |
#batch_size ⇒ Integer
The number of rows to process in a single background migration run
18 19 20 |
# File 'lib/online_migrations/background_migrations/config.rb', line 18 def batch_size @batch_size end |
#error_handler ⇒ Proc
The callback to perform when an error occurs in the migration job.
79 80 81 |
# File 'lib/online_migrations/background_migrations/config.rb', line 79 def error_handler @error_handler end |
#migrations_module ⇒ String
The module in which background migrations will be placed
13 14 15 |
# File 'lib/online_migrations/background_migrations/config.rb', line 13 def migrations_module @migrations_module end |
#migrations_path ⇒ String
The path where generated background migrations will be placed
9 10 11 |
# File 'lib/online_migrations/background_migrations/config.rb', line 9 def migrations_path @migrations_path end |
#stuck_jobs_timeout ⇒ Integer
The number of seconds that must pass before the running job is considered stuck
58 59 60 |
# File 'lib/online_migrations/background_migrations/config.rb', line 58 def stuck_jobs_timeout @stuck_jobs_timeout end |
#sub_batch_pause_ms ⇒ Integer
The number of milliseconds to sleep between each sub_batch execution
33 34 35 |
# File 'lib/online_migrations/background_migrations/config.rb', line 33 def sub_batch_pause_ms @sub_batch_pause_ms end |
#sub_batch_size ⇒ Integer
The smaller batches size that the batches will be divided into
23 24 25 |
# File 'lib/online_migrations/background_migrations/config.rb', line 23 def sub_batch_size @sub_batch_size end |
#throttler ⇒ Proc
Allows to throttle background migrations based on external signal (e.g. database health)
It will be called before each batch run. If throttled, the current run will be retried next time.
52 53 54 |
# File 'lib/online_migrations/background_migrations/config.rb', line 52 def throttler @throttler end |