ClickHouse / terraform-provider-clickhouse

Terraform Provider for ClickHouse Cloud
Apache License 2.0
21 stars 7 forks source link

Handle 429 for each call and use response headers #148

Closed whites11 closed 1 month ago

whites11 commented 1 month ago

Use response headers to handle retry in case a 429 error is returned for each API call.

// The server's quota for requests by the client in the time window.
.header('X-RateLimit-Limit', `${getPoints(type)}`)
// The remaining quota in the current window.
.header('X-RateLimit-Remaining', `${rateLimiterRes.remainingPoints}`)
// The time remaining in the current window specified in seconds.
.header('X-RateLimit-Reset', `${rateLimiterRes.msBeforeNext / MILLIS_PER_SECOND}`)
// Indicates the quota policies currently associated with the client.
.header(
  'X-RateLimit-Policy',
  `${getPoints(type)};w=${getOpenapiApiEnv('rateLimitDuration')};comment="fixed window"`