public static class GoogleAdsV17.SimpleRateLimitPolicy extends java.lang.Object implements GoogleAdsV17.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 GoogleAdsV17.Read or GoogleAdsV17.ReadAll transforms by defining and using a GoogleAdsV17.RateLimitPolicyFactory which holds a shared static GoogleAdsV17.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 GoogleAdsV17.RateLimitPolicyFactory {
private static final GoogleAdsV17.RateLimitPolicy POLICY =
new GoogleAdsV17.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(@Nullable java.lang.String developerToken,
java.lang.String customerId,
com.google.protobuf.Message request)
Called before a request is sent.
|
void |
onError(@Nullable java.lang.String developerToken,
java.lang.String customerId,
com.google.protobuf.Message request,
com.google.ads.googleads.v17.errors.GoogleAdsError error)
Called after a request fails with a retryable error.
|
void |
onSuccess(@Nullable 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(@Nullable java.lang.String developerToken,
java.lang.String customerId,
com.google.protobuf.Message request)
throws java.lang.InterruptedException
GoogleAdsV17.RateLimitPolicyonBeforeRequest in interface GoogleAdsV17.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(@Nullable java.lang.String developerToken,
java.lang.String customerId,
com.google.protobuf.Message request)
GoogleAdsV17.RateLimitPolicyonSuccess in interface GoogleAdsV17.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(@Nullable java.lang.String developerToken,
java.lang.String customerId,
com.google.protobuf.Message request,
com.google.ads.googleads.v17.errors.GoogleAdsError error)
GoogleAdsV17.RateLimitPolicyonError in interface GoogleAdsV17.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.