Class: Gitlab::Database::DatabaseConnectionInfo
- Inherits:
-
Struct
- Object
- Struct
- Gitlab::Database::DatabaseConnectionInfo
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/database/database_connection_info.rb
Instance Attribute Summary collapse
-
#db_dir ⇒ Object
Returns the value of attribute db_dir.
-
#description ⇒ Object
Returns the value of attribute description.
-
#fallback_database ⇒ Object
Returns the value of attribute fallback_database.
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#gitlab_schemas ⇒ Object
Returns the value of attribute gitlab_schemas.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#lock_gitlab_schemas ⇒ Object
Returns the value of attribute lock_gitlab_schemas.
-
#name ⇒ Object
Returns the value of attribute name.
-
#uses_load_balancing ⇒ Object
Returns the value of attribute uses_load_balancing.
Class Method Summary collapse
Instance Method Summary collapse
- #connection_class_or_fallback(all_databases) ⇒ Object
- #db_docs_dir ⇒ Object
- #has_gitlab_shared? ⇒ Boolean
-
#initialize ⇒ DatabaseConnectionInfo
constructor
A new instance of DatabaseConnectionInfo.
- #uses_load_balancing? ⇒ Boolean
Constructor Details
#initialize ⇒ DatabaseConnectionInfo
Returns a new instance of DatabaseConnectionInfo.
19 20 21 22 23 24 25 26 27 |
# File 'lib/gitlab/database/database_connection_info.rb', line 19 def initialize(*) super self.name = name.to_sym self.gitlab_schemas = gitlab_schemas.map(&:to_sym) self.klass = klass.constantize self.lock_gitlab_schemas = (lock_gitlab_schemas || []).map(&:to_sym) self.fallback_database = fallback_database&.to_sym self.db_dir = Rails.root.join(db_dir || 'db') end |
Instance Attribute Details
#db_dir ⇒ Object
Returns the value of attribute db_dir
5 6 7 |
# File 'lib/gitlab/database/database_connection_info.rb', line 5 def db_dir @db_dir end |
#description ⇒ Object
Returns the value of attribute description
5 6 7 |
# File 'lib/gitlab/database/database_connection_info.rb', line 5 def description @description end |
#fallback_database ⇒ Object
Returns the value of attribute fallback_database
5 6 7 |
# File 'lib/gitlab/database/database_connection_info.rb', line 5 def fallback_database @fallback_database end |
#file_path ⇒ Object
Returns the value of attribute file_path
5 6 7 |
# File 'lib/gitlab/database/database_connection_info.rb', line 5 def file_path @file_path end |
#gitlab_schemas ⇒ Object
Returns the value of attribute gitlab_schemas
5 6 7 |
# File 'lib/gitlab/database/database_connection_info.rb', line 5 def gitlab_schemas @gitlab_schemas end |
#klass ⇒ Object
Returns the value of attribute klass
5 6 7 |
# File 'lib/gitlab/database/database_connection_info.rb', line 5 def klass @klass end |
#lock_gitlab_schemas ⇒ Object
Returns the value of attribute lock_gitlab_schemas
5 6 7 |
# File 'lib/gitlab/database/database_connection_info.rb', line 5 def lock_gitlab_schemas @lock_gitlab_schemas end |
#name ⇒ Object
Returns the value of attribute name
5 6 7 |
# File 'lib/gitlab/database/database_connection_info.rb', line 5 def name @name end |
#uses_load_balancing ⇒ Object
Returns the value of attribute uses_load_balancing
5 6 7 |
# File 'lib/gitlab/database/database_connection_info.rb', line 5 def uses_load_balancing @uses_load_balancing end |
Class Method Details
.load_file(yaml_file) ⇒ Object
29 30 31 32 |
# File 'lib/gitlab/database/database_connection_info.rb', line 29 def self.load_file(yaml_file) content = YAML.load_file(yaml_file) new(**content.deep_symbolize_keys.merge(file_path: yaml_file)) end |
Instance Method Details
#connection_class_or_fallback(all_databases) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/gitlab/database/database_connection_info.rb', line 51 def connection_class_or_fallback(all_databases) if connection_class connection_class elsif fallback_database all_databases.fetch(fallback_database) .connection_class_or_fallback(all_databases) end end |
#db_docs_dir ⇒ Object
68 69 70 |
# File 'lib/gitlab/database/database_connection_info.rb', line 68 def db_docs_dir db_dir.join('docs') end |
#has_gitlab_shared? ⇒ Boolean
60 61 62 |
# File 'lib/gitlab/database/database_connection_info.rb', line 60 def has_gitlab_shared? gitlab_schemas.include?(:gitlab_shared) end |
#uses_load_balancing? ⇒ Boolean
64 65 66 |
# File 'lib/gitlab/database/database_connection_info.rb', line 64 def uses_load_balancing? !!uses_load_balancing end |