Class: Gitaly::Server
- Inherits:
-
Object
- Object
- Gitaly::Server
- Defined in:
- lib/gitaly/server.rb
Constant Summary collapse
- SHA_VERSION_REGEX =
/\A\d+\.\d+\.\d+-\d+-g([a-f0-9]{8})\z/
- DEFAULT_REPLICATION_FACTOR =
1
Instance Attribute Summary collapse
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Class Method Summary collapse
Instance Method Summary collapse
- #address ⇒ Object
- #disk_available ⇒ Object
-
#disk_stats ⇒ Object
Simple convenience method for when obtaining both used and available statistics at once is preferred.
- #disk_used ⇒ Object
- #expected_version? ⇒ Boolean (also: #up_to_date?)
- #filesystem_type ⇒ Object
- #git_binary_version ⇒ Object
-
#initialize(storage) ⇒ Server
constructor
A new instance of Server.
- #read_writeable? ⇒ Boolean
- #readable? ⇒ Boolean
- #replication_factor ⇒ Object
- #server_version ⇒ Object
- #writeable? ⇒ Boolean
Constructor Details
#initialize(storage) ⇒ Server
Returns a new instance of Server.
28 29 30 |
# File 'lib/gitaly/server.rb', line 28 def initialize(storage) @storage = storage end |
Instance Attribute Details
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
26 27 28 |
# File 'lib/gitaly/server.rb', line 26 def storage @storage end |
Class Method Details
.all ⇒ Object
9 10 11 |
# File 'lib/gitaly/server.rb', line 9 def all Gitlab.config.repositories.storages.keys.map { |s| Gitaly::Server.new(s) } end |
.count ⇒ Object
13 14 15 |
# File 'lib/gitaly/server.rb', line 13 def count all.size end |
.filesystems ⇒ Object
17 18 19 |
# File 'lib/gitaly/server.rb', line 17 def filesystems all.map(&:filesystem_type).compact.uniq end |
.gitaly_clusters ⇒ Object
21 22 23 |
# File 'lib/gitaly/server.rb', line 21 def gitaly_clusters all.count { |g| g.replication_factor > DEFAULT_REPLICATION_FACTOR } end |
Instance Method Details
#address ⇒ Object
75 76 77 78 79 |
# File 'lib/gitaly/server.rb', line 75 def address Gitlab::GitalyClient.address(@storage) rescue RuntimeError => e "Error getting the address: #{e.}" end |
#disk_available ⇒ Object
65 66 67 |
# File 'lib/gitaly/server.rb', line 65 def disk_available disk_statistics_storage_status&.available end |
#disk_stats ⇒ Object
Simple convenience method for when obtaining both used and available statistics at once is preferred.
71 72 73 |
# File 'lib/gitaly/server.rb', line 71 def disk_stats disk_statistics_storage_status end |
#disk_used ⇒ Object
61 62 63 |
# File 'lib/gitaly/server.rb', line 61 def disk_used disk_statistics_storage_status&.used end |
#expected_version? ⇒ Boolean Also known as: up_to_date?
40 41 42 |
# File 'lib/gitaly/server.rb', line 40 def expected_version? server_version == Gitlab::GitalyClient.expected_server_version || matches_sha? end |
#filesystem_type ⇒ Object
57 58 59 |
# File 'lib/gitaly/server.rb', line 57 def filesystem_type storage_status&.fs_type end |
#git_binary_version ⇒ Object
36 37 38 |
# File 'lib/gitaly/server.rb', line 36 def git_binary_version info.git_version end |
#read_writeable? ⇒ Boolean
45 46 47 |
# File 'lib/gitaly/server.rb', line 45 def read_writeable? readable? && writeable? end |
#readable? ⇒ Boolean
49 50 51 |
# File 'lib/gitaly/server.rb', line 49 def readable? storage_status&.readable end |
#replication_factor ⇒ Object
81 82 83 |
# File 'lib/gitaly/server.rb', line 81 def replication_factor storage_status&.replication_factor end |
#server_version ⇒ Object
32 33 34 |
# File 'lib/gitaly/server.rb', line 32 def server_version info.server_version end |
#writeable? ⇒ Boolean
53 54 55 |
# File 'lib/gitaly/server.rb', line 53 def writeable? storage_status&.writeable end |