Class: Gitlab::GitalyClient::Call

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/gitaly_client/call.rb

Instance Method Summary collapse

Constructor Details

#initialize(storage, service, rpc, request, remote_storage, timeout) ⇒ Call

Returns a new instance of Call.



6
7
8
9
10
11
12
13
14
# File 'lib/gitlab/gitaly_client/call.rb', line 6

def initialize(storage, service, rpc, request, remote_storage, timeout)
  @storage = storage
  @service = service
  @rpc = rpc
  @request = request
  @remote_storage = remote_storage
  @timeout = timeout
  @duration = 0
end

Instance Method Details

#call(&block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/gitlab/gitaly_client/call.rb', line 16

def call(&block)
  response = recording_request do
    GitalyClient.execute(@storage, @service, @rpc, @request, remote_storage: @remote_storage, timeout: @timeout, &block)
  end

  if response.is_a?(Enumerator)
    # When the given response is an enumerator (coming from streamed
    # responses), we wrap it in order to properly measure the stream
    # consumption as it happens.
    #
    # store_timings is not called in that scenario as needs to be
    # handled lazily in the custom Enumerator context.
    instrument_stream(response)
  else
    store_timings
    response
  end
rescue StandardError => err
  store_timings
  (err) if err.is_a?(::GRPC::BadStatus)

  raise err
end