lib/triglav/agent/bigquery/connection.rb in triglav-agent-bigquery-1.0.0.rc3 vs lib/triglav/agent/bigquery/connection.rb in triglav-agent-bigquery-1.0.0

- old
+ new

@@ -57,13 +57,18 @@ def client return @cached_client if @cached_client && @cached_client_expiration > Time.now client = Google::Apis::BigqueryV2::BigqueryService.new client.request_options.retries = retries - client.request_options.timeout_sec = timeout_sec - client.request_options.open_timeout_sec = open_timeout_sec + client.client_options.send_timeout_sec = send_timeout_sec + client.client_options.read_timeout_sec = read_timeout_sec + client.client_options.open_timeout_sec = open_timeout_sec + if timeout_sec + $logger.warn { "timeout_sec is depreacated. Use send_timeout_sec or read_timeout_sec instead" } + end + scope = "https://www.googleapis.com/auth/bigquery" case auth_method when 'authorized_user' auth = Signet::OAuth2::Client.new( @@ -265,11 +270,20 @@ def retries @retries ||= ENV['RETRIES'] || @connection_info.fetch(:retries, nil) || $setting.dig(:bigquery, :retries) || 5 end + # For google-api-client < 0.11.0. Deprecated def timeout_sec - @timeout_sec ||= ENV['TIMEOUT_SEC'] || @connection_info.fetch(:timeout_sec, nil) || $setting.dig(:bigquery, :timeout_sec) || 300 + @timeout_sec ||= ENV['TIMEOUT_SEC'] || @connection_info.fetch(:timeout_sec, nil) || $setting.dig(:bigquery, :timeout_sec) + end + + def send_timeout_sec + @send_timeout_sec ||= ENV['SEND_TIMEOUT_SEC'] || @connection_info.fetch(:send_timeout_sec, nil) || $setting.dig(:bigquery, :send_timeout_sec) || 60 + end + + def read_timeout_sec + @read_timeout_sec ||= ENV['READ_TIMEOUT_SEC'] || @connection_info.fetch(:read_timeout_sec, nil) || $setting.dig(:bigquery, :read_timeout_sec) || timeout_sec || 300 end def open_timeout_sec @open_timeout_sec ||= ENV['OPEN_TIMEOUT_SEC'] || @connection_info.fetch(:open_timeout_sec, nil) || $setting.dig(:bigquery, :open_timeout_sec) || 300 end