public static class GoogleAdsV19.SimpleRateLimitPolicy extends java.lang.Object implements GoogleAdsIO.RateLimitPolicy<com.google.ads.googleads.v19.errors.GoogleAdsError>
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 GoogleAdsV19.Read
or GoogleAdsV19.ReadAll
transforms by defining and using a GoogleAdsV19.RateLimitPolicyFactory
which holds a shared static GoogleAdsV19.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 GoogleAdsIO.RateLimitPolicyFactory { private static final GoogleAdsIO.RateLimitPolicy POLICY = new GoogleAdsV19.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.v19.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
GoogleAdsIO.RateLimitPolicy
onBeforeRequest
in interface GoogleAdsIO.RateLimitPolicy<com.google.ads.googleads.v19.errors.GoogleAdsError>
developerToken
- The developer token used for the request.customerId
- The customer ID specified on the request.request
- Any Google Ads API request.java.lang.InterruptedException
public void onSuccess(@Nullable java.lang.String developerToken, java.lang.String customerId, com.google.protobuf.Message request)
GoogleAdsIO.RateLimitPolicy
onSuccess
in interface GoogleAdsIO.RateLimitPolicy<com.google.ads.googleads.v19.errors.GoogleAdsError>
developerToken
- 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.v19.errors.GoogleAdsError error)
GoogleAdsIO.RateLimitPolicy
onError
in interface GoogleAdsIO.RateLimitPolicy<com.google.ads.googleads.v19.errors.GoogleAdsError>
developerToken
- 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.