gitlab-org--gitlab-foss/lib/gitlab/gitaly_client/object_pool_service.rb
John Cai 5ee7876534 Add client methods for FetchIntoObjectPool RPC
Gitaly's FetchIntoObjectPool RPC will idempotently fetch objects into an
object pool. If the pool doesn't exist, it will create an empty pool
before attempting the fetch. This change adds client code as well as
specs to cover this behavior.
2019-04-30 08:28:56 -07:00

47 lines
1.4 KiB
Ruby

# frozen_string_literal: true
module Gitlab
module GitalyClient
class ObjectPoolService
attr_reader :object_pool, :storage
def initialize(object_pool)
@object_pool = object_pool.gitaly_object_pool
@storage = object_pool.storage
end
def create(repository)
request = Gitaly::CreateObjectPoolRequest.new(
object_pool: object_pool,
origin: repository.gitaly_repository)
GitalyClient.call(storage, :object_pool_service, :create_object_pool, request)
end
def delete
request = Gitaly::DeleteObjectPoolRequest.new(object_pool: object_pool)
GitalyClient.call(storage, :object_pool_service, :delete_object_pool, request)
end
def link_repository(repository)
request = Gitaly::LinkRepositoryToObjectPoolRequest.new(
object_pool: object_pool,
repository: repository.gitaly_repository
)
GitalyClient.call(storage, :object_pool_service, :link_repository_to_object_pool,
request, timeout: GitalyClient.fast_timeout)
end
def fetch(repository)
request = Gitaly::FetchIntoObjectPoolRequest.new(
object_pool: object_pool,
origin: repository.gitaly_repository
)
GitalyClient.call(storage, :object_pool_service, :fetch_into_object_pool, request)
end
end
end
end