Class: Gitaly::Server
- Inherits:
-
Object
- Object
- Gitaly::Server
- Defined in:
- lib/gitaly/server.rb
Defined Under Namespace
Classes: ServerSignature
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_signature_error? ⇒ Boolean
- #server_signature_public_key ⇒ Object
- #server_version ⇒ Object
- #writeable? ⇒ Boolean
Constructor Details
#initialize(storage) ⇒ Server
Returns a new instance of Server.
30 31 32 |
# File 'lib/gitaly/server.rb', line 30 def initialize(storage) @storage = storage end |
Instance Attribute Details
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
28 29 30 |
# File 'lib/gitaly/server.rb', line 28 def storage @storage end |
Class Method Details
.all ⇒ Object
11 12 13 |
# File 'lib/gitaly/server.rb', line 11 def all Gitlab.config.repositories.storages.keys.map { |s| Gitaly::Server.new(s) } end |
.count ⇒ Object
15 16 17 |
# File 'lib/gitaly/server.rb', line 15 def count all.size end |
.filesystems ⇒ Object
19 20 21 |
# File 'lib/gitaly/server.rb', line 19 def filesystems all.map(&:filesystem_type).compact.uniq end |
.gitaly_clusters ⇒ Object
23 24 25 |
# File 'lib/gitaly/server.rb', line 23 def gitaly_clusters all.count { |g| g.replication_factor > DEFAULT_REPLICATION_FACTOR } end |
Instance Method Details
#address ⇒ Object
85 86 87 88 89 |
# File 'lib/gitaly/server.rb', line 85 def address Gitlab::GitalyClient.address(@storage) rescue RuntimeError => e "Error getting the address: #{e.}" end |
#disk_available ⇒ Object
75 76 77 |
# File 'lib/gitaly/server.rb', line 75 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.
81 82 83 |
# File 'lib/gitaly/server.rb', line 81 def disk_stats disk_statistics_storage_status end |
#disk_used ⇒ Object
71 72 73 |
# File 'lib/gitaly/server.rb', line 71 def disk_used disk_statistics_storage_status&.used end |
#expected_version? ⇒ Boolean Also known as: up_to_date?
42 43 44 |
# File 'lib/gitaly/server.rb', line 42 def expected_version? server_version == Gitlab::GitalyClient.expected_server_version || matches_sha? end |
#filesystem_type ⇒ Object
59 60 61 |
# File 'lib/gitaly/server.rb', line 59 def filesystem_type storage_status&.fs_type end |
#git_binary_version ⇒ Object
38 39 40 |
# File 'lib/gitaly/server.rb', line 38 def git_binary_version info.git_version end |
#read_writeable? ⇒ Boolean
47 48 49 |
# File 'lib/gitaly/server.rb', line 47 def read_writeable? readable? && writeable? end |
#readable? ⇒ Boolean
51 52 53 |
# File 'lib/gitaly/server.rb', line 51 def readable? storage_status&.readable end |
#replication_factor ⇒ Object
91 92 93 |
# File 'lib/gitaly/server.rb', line 91 def replication_factor storage_status&.replication_factor end |
#server_signature_error? ⇒ Boolean
67 68 69 |
# File 'lib/gitaly/server.rb', line 67 def server_signature_error? !!server_signature.try(:error) end |
#server_signature_public_key ⇒ Object
63 64 65 |
# File 'lib/gitaly/server.rb', line 63 def server_signature_public_key server_signature&.public_key end |
#server_version ⇒ Object
34 35 36 |
# File 'lib/gitaly/server.rb', line 34 def server_version info.server_version end |
#writeable? ⇒ Boolean
55 56 57 |
# File 'lib/gitaly/server.rb', line 55 def writeable? storage_status&.writeable end |