Class: Gitaly::Server

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

Class Method Summary collapse

Instance Method Summary collapse

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

#storageObject (readonly)

Returns the value of attribute storage.



26
27
28
# File 'lib/gitaly/server.rb', line 26

def storage
  @storage
end

Class Method Details

.allObject



9
10
11
# File 'lib/gitaly/server.rb', line 9

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

.countObject



13
14
15
# File 'lib/gitaly/server.rb', line 13

def count
  all.size
end

.filesystemsObject



17
18
19
# File 'lib/gitaly/server.rb', line 17

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

.gitaly_clustersObject



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

#addressObject



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

#disk_availableObject



65
66
67
# File 'lib/gitaly/server.rb', line 65

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.



71
72
73
# File 'lib/gitaly/server.rb', line 71

def disk_stats
  disk_statistics_storage_status
end

#disk_usedObject



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?

Returns:

  • (Boolean)


40
41
42
# File 'lib/gitaly/server.rb', line 40

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

#filesystem_typeObject



57
58
59
# File 'lib/gitaly/server.rb', line 57

def filesystem_type
  storage_status&.fs_type
end

#git_binary_versionObject



36
37
38
# File 'lib/gitaly/server.rb', line 36

def git_binary_version
  info.git_version
end

#read_writeable?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/gitaly/server.rb', line 45

def read_writeable?
  readable? && writeable?
end

#readable?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/gitaly/server.rb', line 49

def readable?
  storage_status&.readable
end

#replication_factorObject



81
82
83
# File 'lib/gitaly/server.rb', line 81

def replication_factor
  storage_status&.replication_factor
end

#server_versionObject



32
33
34
# File 'lib/gitaly/server.rb', line 32

def server_version
  info.server_version
end

#writeable?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/gitaly/server.rb', line 53

def writeable?
  storage_status&.writeable
end