Class: Gitaly::Server

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#storageObject (readonly)

Returns the value of attribute storage.



28
29
30
# File 'lib/gitaly/server.rb', line 28

def storage
  @storage
end

Class Method Details

.allObject



11
12
13
# File 'lib/gitaly/server.rb', line 11

def all
  Gitlab.config.repositories.storages.keys.map { |s| Gitaly::Server.new(s) }
end

.countObject



15
16
17
# File 'lib/gitaly/server.rb', line 15

def count
  all.size
end

.filesystemsObject



19
20
21
# File 'lib/gitaly/server.rb', line 19

def filesystems
  all.map(&:filesystem_type).compact.uniq
end

.gitaly_clustersObject



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

#addressObject



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.message}"
end

#disk_availableObject



75
76
77
# File 'lib/gitaly/server.rb', line 75

def disk_available
  disk_statistics_storage_status&.available
end

#disk_statsObject

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_usedObject



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?

Returns:

  • (Boolean)


42
43
44
# File 'lib/gitaly/server.rb', line 42

def expected_version?
  server_version == Gitlab::GitalyClient.expected_server_version || matches_sha?
end

#filesystem_typeObject



59
60
61
# File 'lib/gitaly/server.rb', line 59

def filesystem_type
  storage_status&.fs_type
end

#git_binary_versionObject



38
39
40
# File 'lib/gitaly/server.rb', line 38

def git_binary_version
  info.git_version
end

#read_writeable?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/gitaly/server.rb', line 47

def read_writeable?
  readable? && writeable?
end

#readable?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/gitaly/server.rb', line 51

def readable?
  storage_status&.readable
end

#replication_factorObject



91
92
93
# File 'lib/gitaly/server.rb', line 91

def replication_factor
  storage_status&.replication_factor
end

#server_signature_error?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/gitaly/server.rb', line 67

def server_signature_error?
  !!server_signature.try(:error)
end

#server_signature_public_keyObject



63
64
65
# File 'lib/gitaly/server.rb', line 63

def server_signature_public_key
  server_signature&.public_key
end

#server_versionObject



34
35
36
# File 'lib/gitaly/server.rb', line 34

def server_version
  info.server_version
end

#writeable?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/gitaly/server.rb', line 55

def writeable?
  storage_status&.writeable
end