Class: Nandi::MultiDatabase::Database
- Inherits:
-
Object
- Object
- Nandi::MultiDatabase::Database
- Defined in:
- lib/nandi/multi_database.rb
Constant Summary collapse
- DEFAULT_ACCESS_EXCLUSIVE_STATEMENT_TIMEOUT =
Most DDL changes take a very strict lock, but execute very quickly. For these the statement timeout should be very tight, so that if there’s an unexpected delay the query queue does not back up.
1_500
- DEFAULT_ACCESS_EXCLUSIVE_LOCK_TIMEOUT =
5_000
- DEFAULT_ACCESS_EXCLUSIVE_STATEMENT_TIMEOUT_LIMIT =
DEFAULT_ACCESS_EXCLUSIVE_STATEMENT_TIMEOUT
- DEFAULT_ACCESS_EXCLUSIVE_LOCK_TIMEOUT_LIMIT =
DEFAULT_ACCESS_EXCLUSIVE_LOCK_TIMEOUT
- DEFAULT_CONCURRENT_TIMEOUT_LIMIT =
3_600_000
- DEFAULT_MIGRATION_DIRECTORY =
"db/safe_migrations"
- DEFAULT_OUTPUT_DIRECTORY =
"db/migrate"
Instance Attribute Summary collapse
-
#access_exclusive_lock_timeout ⇒ Integer
The default lock timeout for migrations that take ACCESS EXCLUSIVE locks.
-
#access_exclusive_lock_timeout_limit ⇒ Integer
The maximum statement timeout for migrations that take an ACCESS EXCLUSIVE lock and therefore block all reads and writes.
-
#access_exclusive_statement_timeout ⇒ Integer
The default statement timeout for migrations that take ACCESS EXCLUSIVE locks.
-
#access_exclusive_statement_timeout_limit ⇒ Integer
The maximum lock timeout for migrations that take an ACCESS EXCLUSIVE lock and therefore block all reads and writes.
-
#concurrent_lock_timeout_limit ⇒ Integer
The minimum lock timeout for migrations that take place concurrently.
-
#concurrent_statement_timeout_limit ⇒ Integer
The minimum statement timeout for migrations that take place concurrently.
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#lockfile_name ⇒ Object
Returns the value of attribute lockfile_name.
-
#migration_directory ⇒ Object
Returns the value of attribute migration_directory.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#output_directory ⇒ String
The directory for output files.
-
#raw_config ⇒ Object
readonly
Returns the value of attribute raw_config.
Instance Method Summary collapse
-
#initialize(name:, config:) ⇒ Database
constructor
A new instance of Database.
Constructor Details
#initialize(name:, config:) ⇒ Database
Returns a new instance of Database.
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/nandi/multi_database.rb', line 62 def initialize(name:, config:) @name = name @raw_config = config @default = @name == :primary || config[:default] == true # Paths and files @migration_directory = config[:migration_directory] || "db/#{path_prefix(name, default)}safe_migrations" @output_directory = config[:output_directory] || "db/#{path_prefix(name, default)}migrate" @lockfile_name = config[:lockfile_name] || ".#{path_prefix(name, default)}nandilock.yml" timeout_limits(config) end |
Instance Attribute Details
#access_exclusive_lock_timeout ⇒ Integer
The default lock timeout for migrations that take ACCESS EXCLUSIVE locks. Can be overridden by way of the ‘set_lock_timeout` class method in a given migration. Default: 1500ms.
25 26 27 |
# File 'lib/nandi/multi_database.rb', line 25 def access_exclusive_lock_timeout @access_exclusive_lock_timeout end |
#access_exclusive_lock_timeout_limit ⇒ Integer
The maximum statement timeout for migrations that take an ACCESS EXCLUSIVE lock and therefore block all reads and writes. Default: 1500ms.
41 42 43 |
# File 'lib/nandi/multi_database.rb', line 41 def access_exclusive_lock_timeout_limit @access_exclusive_lock_timeout_limit end |
#access_exclusive_statement_timeout ⇒ Integer
The default statement timeout for migrations that take ACCESS EXCLUSIVE locks. Can be overridden by way of the ‘set_statement_timeout` class method in a given migration. Default: 1500ms.
31 32 33 |
# File 'lib/nandi/multi_database.rb', line 31 def access_exclusive_statement_timeout @access_exclusive_statement_timeout end |
#access_exclusive_statement_timeout_limit ⇒ Integer
The maximum lock timeout for migrations that take an ACCESS EXCLUSIVE lock and therefore block all reads and writes. Default: 5,000ms.
36 37 38 |
# File 'lib/nandi/multi_database.rb', line 36 def access_exclusive_statement_timeout_limit @access_exclusive_statement_timeout_limit end |
#concurrent_lock_timeout_limit ⇒ Integer
The minimum lock timeout for migrations that take place concurrently. Default: 3,600,000ms (ie, 3 hours).
51 52 53 |
# File 'lib/nandi/multi_database.rb', line 51 def concurrent_lock_timeout_limit @concurrent_lock_timeout_limit end |
#concurrent_statement_timeout_limit ⇒ Integer
The minimum statement timeout for migrations that take place concurrently. Default: 3,600,000ms (ie, 3 hours).
46 47 48 |
# File 'lib/nandi/multi_database.rb', line 46 def concurrent_statement_timeout_limit @concurrent_statement_timeout_limit end |
#default ⇒ Object (readonly)
Returns the value of attribute default.
57 58 59 |
# File 'lib/nandi/multi_database.rb', line 57 def default @default end |
#lockfile_name ⇒ Object
Returns the value of attribute lockfile_name.
59 60 61 |
# File 'lib/nandi/multi_database.rb', line 59 def lockfile_name @lockfile_name end |
#migration_directory ⇒ Object
Returns the value of attribute migration_directory.
59 60 61 |
# File 'lib/nandi/multi_database.rb', line 59 def migration_directory @migration_directory end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
57 58 59 |
# File 'lib/nandi/multi_database.rb', line 57 def name @name end |
#output_directory ⇒ String
The directory for output files. Default: ‘db/migrate`
55 56 57 |
# File 'lib/nandi/multi_database.rb', line 55 def output_directory @output_directory end |
#raw_config ⇒ Object (readonly)
Returns the value of attribute raw_config.
57 58 59 |
# File 'lib/nandi/multi_database.rb', line 57 def raw_config @raw_config end |