Ruby 클라이언트 라이브러리의 각 서비스에는 해당 서비스의 client.rb 파일에 지정된 기본 시간 제한 및 재시도 정책이 함께 제공됩니다. 예를 들어 CampaignService 클라이언트 구성에서 self.configure 메서드를 검사할 수 있습니다.
기본 제한 시간 재정의
서비스 수준 config.timeout (초)를 설정하거나 config.rpcs에서 개별 RPC 메서드에 대해 timeout 및 retry_policy를 구성하여 인스턴스화한 후 서비스 인스턴스에서 이러한 기본값을 재정의할 수 있습니다.
require 'google/ads/google_ads'
client = Google::Ads::GoogleAds::GoogleAdsClient.new
ga_service = client.service.google_ads
ga_service.configure do |config|
# Set the default timeout (in seconds) for all RPCs on this service instance.
config.timeout = 120.0
# Override the timeout or retry policy for specific RPC methods.
config.rpcs.search_stream.timeout = 300.0
config.rpcs.search.timeout = 120.0
config.rpcs.search.retry_policy = {
'initial_delay' => 5.0,
'max_delay' => 60.0
}
end
완전한 작동 스크립트는 GitHub의 set_custom_client_timeouts.rb 코드 예시를 참고하세요.
시간 제한 및 오류
클라이언트 제한 시간은 늘릴 수 있지만 서버 측 제한은 계속 적용됩니다. 2시간 이상 걸리는 요청은 실패하고 DEADLINE_EXCEEDED 상태로 Google::Ads::GoogleAds::Errors::GoogleAdsError 또는 GRPC::DeadlineExceeded 예외가 발생할 수 있습니다.