public static class GoogleAdsV14.SimpleRateLimitPolicy extends java.lang.Object implements GoogleAdsV14.RateLimitPolicy
RateLimiter and can be used in low volume and
development use cases as a client-side rate limiting policy. This policy does not enforce a
global (per pipeline or otherwise) rate limit to requests and should not be used in deployments
where the Google Ads API quota is shared between multiple applications.
This policy can be used to limit requests across all GoogleAdsV14.Read or GoogleAdsV14.ReadAll transforms by defining and using a GoogleAdsV14.RateLimitPolicyFactory which holds a shared static GoogleAdsV14.SimpleRateLimitPolicy. Note that the desired rate must be divided by the expected
maximum number of workers for the pipeline, otherwise the pipeline may exceed the desired rate
after an upscaling event.
{@code
public class SimpleRateLimitPolicyFactory implements GoogleAdsV14.RateLimitPolicyFactory {
private static final GoogleAdsV14.RateLimitPolicy POLICY =
new GoogleAdsV14.SimpleRateLimitPolicy(1.0 / 1000.0);| Constructor and Description |
|---|
SimpleRateLimitPolicy(double permitsPerSecond) |
SimpleRateLimitPolicy(double permitsPerSecond,
long warmupPeriod,
java.util.concurrent.TimeUnit unit) |
| Modifier and Type | Method and Description |
|---|---|
void |
onBeforeRequest(java.lang.String developerToken,
java.lang.String customerId,
com.google.protobuf.Message request)
Called before a request is sent.
|
void |
onError(java.lang.String developerToken,
java.lang.String customerId,
com.google.protobuf.Message request,
com.google.ads.googleads.v14.errors.GoogleAdsError error)
Called after a request fails with a retryable error.
|
void |
onSuccess(java.lang.String developerToken,
java.lang.String customerId,
com.google.protobuf.Message request)
Called after a request succeeds.
|
public SimpleRateLimitPolicy(double permitsPerSecond)
public SimpleRateLimitPolicy(double permitsPerSecond,
long warmupPeriod,
java.util.concurrent.TimeUnit unit)
public void onBeforeRequest(java.lang.String developerToken,
java.lang.String customerId,
com.google.protobuf.Message request)
throws java.lang.InterruptedException
GoogleAdsV14.RateLimitPolicyonBeforeRequest in interface GoogleAdsV14.RateLimitPolicydeveloperToken - The developer token used for the request.customerId - The customer ID specified on the request.request - Any Google Ads API request.java.lang.InterruptedExceptionpublic void onSuccess(java.lang.String developerToken,
java.lang.String customerId,
com.google.protobuf.Message request)
GoogleAdsV14.RateLimitPolicyonSuccess in interface GoogleAdsV14.RateLimitPolicydeveloperToken - The developer token used for the request.customerId - The customer ID specified on the request.request - Any Google Ads API request.public void onError(java.lang.String developerToken,
java.lang.String customerId,
com.google.protobuf.Message request,
com.google.ads.googleads.v14.errors.GoogleAdsError error)
GoogleAdsV14.RateLimitPolicyonError in interface GoogleAdsV14.RateLimitPolicydeveloperToken - The developer token used for the request.customerId - The customer ID specified on the request.request - Any Google Ads API request.error - A retryable error.