26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/webex/client.rb', line 26
def self.query(query:, operation_name:, variables: {}, options: {})
Webex::Helpers.assert_access_token!
logger = Events::Config.logger
logger.info("Begin to HTTP request to #{Webex::Helpers.endpoint_url}...")
retries = -1
start_time = Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond)
response = Retriable.retriable(on: EXCEPTIONS, tries: Webex::Events::Config.max_retries) do
retries += 1
if retries > 0
logger.info("Retrying the request. Retry count: #{retries}")
end
Request.execute(
query: query,
variables: variables,
operation_name: operation_name,
options: options
)
end
end_time = Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond)
response.retry_count = retries
response.time_spent_in_ms = end_time - start_time
logger.info("The HTTP request is finished. The request took #{response.time_spent_in_ms} ms.")
response
end
|