Class: OnlineMigrations::BackgroundMigrations::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/online_migrations/background_migrations/config.rb

Overview

Class representing configuration options for background migrations.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/online_migrations/background_migrations/config.rb', line 61

def initialize
  @migrations_path = "lib"
  @migrations_module = "OnlineMigrations::BackgroundMigrations"
  @batch_size = 1_000
  @sub_batch_size = 100
  @batch_pause = 0.seconds
  @sub_batch_pause_ms = 100
  @batch_max_attempts = 5
  @stuck_jobs_timeout = 1.hour
  @error_handler = ->(error, errored_job) {}
end

Instance Attribute Details

#batch_max_attemptsInteger

Maximum number of batch run attempts

When attempts are exhausted, the individual batch is marked as failed.

Returns:

  • (Integer)

    defaults to 5



40
41
42
# File 'lib/online_migrations/background_migrations/config.rb', line 40

def batch_max_attempts
  @batch_max_attempts
end

#batch_pauseInteger

The pause interval between each background migration job's execution (in seconds)

Returns:

  • (Integer)

    defaults to 0



28
29
30
# File 'lib/online_migrations/background_migrations/config.rb', line 28

def batch_pause
  @batch_pause
end

#batch_sizeInteger

The number of rows to process in a single background migration run

Returns:

  • (Integer)

    defaults to 1_000



18
19
20
# File 'lib/online_migrations/background_migrations/config.rb', line 18

def batch_size
  @batch_size
end

#error_handlerProc

The callback to perform when an error occurs in the migration job.

Examples:

OnlineMigrations.config.background_migrations.error_handler = ->(error, errored_job) do
  Bugsnag.notify(error) do |notification|
    notification.(:background_migration, { name: errored_job.migration_name })
  end
end

Returns:

  • (Proc)

    the callback to perform when an error occurs in the migration job



59
60
61
# File 'lib/online_migrations/background_migrations/config.rb', line 59

def error_handler
  @error_handler
end

#migrations_moduleString

The module in which background migrations will be placed

Returns:

  • (String)

    defaults to "OnlineMigrations::BackgroundMigrations"



13
14
15
# File 'lib/online_migrations/background_migrations/config.rb', line 13

def migrations_module
  @migrations_module
end

#migrations_pathString

The path where generated background migrations will be placed

Returns:

  • (String)

    defaults to "lib"



9
10
11
# File 'lib/online_migrations/background_migrations/config.rb', line 9

def migrations_path
  @migrations_path
end

#stuck_jobs_timeoutInteger

The number of seconds that must pass before the running job is considered stuck

Returns:

  • (Integer)

    defaults to 1 hour



46
47
48
# File 'lib/online_migrations/background_migrations/config.rb', line 46

def stuck_jobs_timeout
  @stuck_jobs_timeout
end

#sub_batch_pause_msInteger

The number of milliseconds to sleep between each sub_batch execution

Returns:

  • (Integer)

    defaults to 100 milliseconds



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_sizeInteger

The smaller batches size that the batches will be divided into

Returns:

  • (Integer)

    defaults to 100



23
24
25
# File 'lib/online_migrations/background_migrations/config.rb', line 23

def sub_batch_size
  @sub_batch_size
end