Skip to content

Commit

Permalink
Add new "retry" field in the throttle overrides object
Browse files Browse the repository at this point in the history
  • Loading branch information
standielpls authored and kola-er committed Mar 27, 2024
1 parent 75c933e commit 46da867
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 46 deletions.
4 changes: 4 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3670,6 +3670,7 @@ <h2 id="adding-throttle-configuration">Adding Throttle Configuration</h2>
<li><code>window [integer]</code>: Same description as above.</li>
<li><code>limit [integer]</code>: Same description as above.</li>
<li><code>filter [string]</code>: Account-based attribute to override the throttle by. You can set to one of the following: &quot;free&quot;, &quot;trial&quot;, &quot;paid&quot;. Therefore, the throttle scope would be automatically set to &quot;account&quot; and ONLY the accounts based on the specified filter will have their requests throttled based on the throttle overrides while the rest are throttled based on the original configuration.</li>
<li><code>retry [boolean]</code> (<em>added in v15.6.1</em>): The effect of throttling on the tasks of the action. <code>true</code> means throttled tasks are automatically retried after some delay, while <code>false</code> means tasks are held without retry. It defaults to <code>true</code>.</li>
</ul>
</li>
</ol><p>Both <code>window</code> and <code>limit</code> are required and others are optional. By default, throttling is scoped to the action and account.</p><p>Here is a typical usage of the throttle configuration:</p>
Expand Down Expand Up @@ -3707,16 +3708,19 @@ <h2 id="adding-throttle-configuration">Adding Throttle Configuration</h2>
<span class="hljs-attr">window</span>: <span class="hljs-number">600</span>,
<span class="hljs-attr">limit</span>: <span class="hljs-number">10</span>,
<span class="hljs-attr">filter</span>: <span class="hljs-string">&apos;free&apos;</span>,
<span class="hljs-attr">retry</span>: <span class="hljs-literal">false</span>,
},
{
<span class="hljs-attr">window</span>: <span class="hljs-number">600</span>,
<span class="hljs-attr">limit</span>: <span class="hljs-number">100</span>,
<span class="hljs-attr">filter</span>: <span class="hljs-string">&apos;trial&apos;</span>,
<span class="hljs-attr">retry</span>: <span class="hljs-literal">false</span>,
},
{
<span class="hljs-attr">window</span>: <span class="hljs-number">0</span>,
<span class="hljs-attr">limit</span>: <span class="hljs-number">0</span>,
<span class="hljs-attr">filter</span>: <span class="hljs-string">&apos;paid&apos;</span>,
<span class="hljs-attr">retry</span>: <span class="hljs-literal">true</span>,
},
],
},
Expand Down
1 change: 1 addition & 0 deletions packages/cli/README-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,7 @@ To throttle an action, you need to set a `throttle` object with the following va
- `window [integer]`: Same description as above.
- `limit [integer]`: Same description as above.
- `filter [string]`: Account-based attribute to override the throttle by. You can set to one of the following: "free", "trial", "paid". Therefore, the throttle scope would be automatically set to "account" and ONLY the accounts based on the specified filter will have their requests throttled based on the throttle overrides while the rest are throttled based on the original configuration.
- `retry [boolean]` (_added in v15.6.1_): The effect of throttling on the tasks of the action. `true` means throttled tasks are automatically retried after some delay, while `false` means tasks are held without retry. It defaults to `true`.
Both `window` and `limit` are required and others are optional. By default, throttling is scoped to the action and account.
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2175,6 +2175,7 @@ To throttle an action, you need to set a `throttle` object with the following va
- `window [integer]`: Same description as above.
- `limit [integer]`: Same description as above.
- `filter [string]`: Account-based attribute to override the throttle by. You can set to one of the following: "free", "trial", "paid". Therefore, the throttle scope would be automatically set to "account" and ONLY the accounts based on the specified filter will have their requests throttled based on the throttle overrides while the rest are throttled based on the original configuration.
- `retry [boolean]` (_added in v15.6.1_): The effect of throttling on the tasks of the action. `true` means throttled tasks are automatically retried after some delay, while `false` means tasks are held without retry. It defaults to `true`.
Both `window` and `limit` are required and others are optional. By default, throttling is scoped to the action and account.
Expand Down Expand Up @@ -2213,16 +2214,19 @@ const App = {
window: 600,
limit: 10,
filter: 'free',
retry: false,
},
{
window: 600,
limit: 100,
filter: 'trial',
retry: false,
},
{
window: 0,
limit: 0,
filter: 'paid',
retry: true,
},
],
},
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3670,6 +3670,7 @@ <h2 id="adding-throttle-configuration">Adding Throttle Configuration</h2>
<li><code>window [integer]</code>: Same description as above.</li>
<li><code>limit [integer]</code>: Same description as above.</li>
<li><code>filter [string]</code>: Account-based attribute to override the throttle by. You can set to one of the following: &quot;free&quot;, &quot;trial&quot;, &quot;paid&quot;. Therefore, the throttle scope would be automatically set to &quot;account&quot; and ONLY the accounts based on the specified filter will have their requests throttled based on the throttle overrides while the rest are throttled based on the original configuration.</li>
<li><code>retry [boolean]</code> (<em>added in v15.6.1</em>): The effect of throttling on the tasks of the action. <code>true</code> means throttled tasks are automatically retried after some delay, while <code>false</code> means tasks are held without retry. It defaults to <code>true</code>.</li>
</ul>
</li>
</ol><p>Both <code>window</code> and <code>limit</code> are required and others are optional. By default, throttling is scoped to the action and account.</p><p>Here is a typical usage of the throttle configuration:</p>
Expand Down Expand Up @@ -3707,16 +3708,19 @@ <h2 id="adding-throttle-configuration">Adding Throttle Configuration</h2>
<span class="hljs-attr">window</span>: <span class="hljs-number">600</span>,
<span class="hljs-attr">limit</span>: <span class="hljs-number">10</span>,
<span class="hljs-attr">filter</span>: <span class="hljs-string">&apos;free&apos;</span>,
<span class="hljs-attr">retry</span>: <span class="hljs-literal">false</span>,
},
{
<span class="hljs-attr">window</span>: <span class="hljs-number">600</span>,
<span class="hljs-attr">limit</span>: <span class="hljs-number">100</span>,
<span class="hljs-attr">filter</span>: <span class="hljs-string">&apos;trial&apos;</span>,
<span class="hljs-attr">retry</span>: <span class="hljs-literal">false</span>,
},
{
<span class="hljs-attr">window</span>: <span class="hljs-number">0</span>,
<span class="hljs-attr">limit</span>: <span class="hljs-number">0</span>,
<span class="hljs-attr">filter</span>: <span class="hljs-string">&apos;paid&apos;</span>,
<span class="hljs-attr">retry</span>: <span class="hljs-literal">true</span>,
},
],
},
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/snippets/throttle-configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@ const App = {
window: 600,
limit: 10,
filter: 'free',
retry: false,
},
{
window: 600,
limit: 100,
filter: 'trial',
retry: false,
},
{
window: 0,
limit: 0,
filter: 'paid',
retry: true,
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions packages/schema/docs/build/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,7 @@ Key | Required | Type | Description
`limit` | **yes** | `integer` | The maximum number of invocations for an action, allowed within the timeframe window.
`key` | no | `string` | The key to throttle with in combination with the scope. User data provided for the input fields can be used in the key with the use of the curly braces referencing. For example, to access the user data provided for the input field "test_field", use `{{bundle.inputData.test_field}}`. Note that a required input field should be referenced to get user data always.
`scope` | no | `array`[`string` in (`'user'`, `'auth'`, `'account'`, `'action'`)] | The granularity to throttle by. You can set the scope to one or more of the following: 'user' - Throttles based on user ids. 'auth' - Throttles based on auth ids. 'account' - Throttles based on account ids for all users under a single account. 'action' - Throttles the action it is set on separately from other actions. By default, throttling is scoped to the action and account.
`overrides` | no | `array`[`object`] | EXPERIMENTAL: Overrides the original throttle configuration based on a Zapier account attribute.
`overrides` | no | [/ThrottleOverrideObjectSchema](#throttleoverrideobjectschema) | EXPERIMENTAL: Overrides the original throttle configuration based on a Zapier account attribute.

#### Examples

Expand All @@ -2103,7 +2103,7 @@ Key | Required | Type | Description
window: 3600,
limit: 10,
scope: [ 'auth' ],
overrides: [ { window: 3600, limit: 2, filter: 'free' } ]
overrides: [ { window: 3600, limit: 2, filter: 'free', retry: false } ]
}
```

Expand Down
18 changes: 1 addition & 17 deletions packages/schema/exported-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -694,23 +694,7 @@
"overrides": {
"description": "EXPERIMENTAL: Overrides the original throttle configuration based on a Zapier account attribute.",
"type": "array",
"items": {
"type": "object",
"properties": {
"window": {
"description": "The timeframe, in seconds, within which the system tracks the number of invocations for an action. The number of invocations begins at zero at the start of each window.",
"type": "integer"
},
"limit": {
"description": "The maximum number of invocations for an action, allowed within the timeframe window.",
"type": "integer"
},
"filter": {
"description": "Account-based attribute to override the throttle by. You can set to one of the following: \"free\", \"trial\", \"paid\". Therefore, the throttle scope would be automatically set to \"account\" and ONLY the accounts based on the specified filter will have their requests throttled based on the throttle overrides while the rest are throttled based on the original configuration.",
"type": "string"
}
}
}
"$ref": "/ThrottleOverrideObjectSchema"
}
},
"additionalProperties": false
Expand Down
42 changes: 15 additions & 27 deletions packages/schema/lib/schemas/ThrottleObjectSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

const makeSchema = require('../utils/makeSchema');

const ThrottleOverrideObjectSchema = require('./ThrottleOverrideObjectSchema');

module.exports = makeSchema({
id: '/ThrottleObjectSchema',
description:
Expand Down Expand Up @@ -34,27 +36,10 @@ module.exports = makeSchema({
},
},
overrides: {
description: 'EXPERIMENTAL: Overrides the original throttle configuration based on a Zapier account attribute.',
description:
'EXPERIMENTAL: Overrides the original throttle configuration based on a Zapier account attribute.',
type: 'array',
items: {
type: 'object',
properties: {
window: {
description:
'The timeframe, in seconds, within which the system tracks the number of invocations for an action. The number of invocations begins at zero at the start of each window.',
type: 'integer',
},
limit: {
description:
'The maximum number of invocations for an action, allowed within the timeframe window.',
type: 'integer',
},
filter: {
description: `Account-based attribute to override the throttle by. You can set to one of the following: "free", "trial", "paid". Therefore, the throttle scope would be automatically set to "account" and ONLY the accounts based on the specified filter will have their requests throttled based on the throttle overrides while the rest are throttled based on the original configuration.`,
type: 'string',
},
}
},
$ref: ThrottleOverrideObjectSchema.id,
},
},
examples: [
Expand Down Expand Up @@ -88,11 +73,14 @@ module.exports = makeSchema({
window: 3600,
limit: 10,
scope: ['auth'],
overrides: [{
window: 3600,
limit: 2,
filter: 'free',
}],
overrides: [
{
window: 3600,
limit: 2,
filter: 'free',
retry: false,
},
],
},
],
antiExamples: [
Expand All @@ -105,11 +93,11 @@ module.exports = makeSchema({
reason: 'Invalid scope provided: `zap`.',
},
{
example: {limit: 10},
example: { limit: 10 },
reason: 'Missing required key: `window`.',
},
{
example: {window: 600},
example: { window: 600 },
reason: 'Missing required key: `limit`.',
},
{
Expand Down
70 changes: 70 additions & 0 deletions packages/schema/lib/schemas/ThrottleOverrideObjectSchema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
'use strict';

const makeSchema = require('../utils/makeSchema');

module.exports = makeSchema({
id: '/ThrottleOverrideObjectSchema',
description:
'EXPERIMENTAL: Overrides the original throttle configuration based on a Zapier account attribute.',
type: 'object',
required: ['window', 'limit', 'filter'],
properties: {
window: {
description:
'The timeframe, in seconds, within which the system tracks the number of invocations for an action. The number of invocations begins at zero at the start of each window.',
type: 'integer',
},
limit: {
description:
'The maximum number of invocations for an action, allowed within the timeframe window.',
type: 'integer',
},
filter: {
description: `Account-based attribute to override the throttle by. You can set to one of the following: "free", "trial", "paid". Therefore, the throttle scope would be automatically set to "account" and ONLY the accounts based on the specified filter will have their requests throttled based on the throttle overrides while the rest are throttled based on the original configuration.`,
type: 'string',
},
retry: {
description:
'The effect of throttling on the tasks of the action. `true` means throttled tasks are automatically retried after some delay, while `false` means tasks are held without retry. It defaults to `true`.',
type: 'boolean',
},
},
examples: [
{
window: 60,
limit: 100,
filter: 'free',
},
{
window: 60,
limit: 100,
filter: 'paid',
retry: false,
},
{
window: 60,
limit: 100,
filter: 'trial',
retry: true,
},
],
antiExamples: [
{
example: { limit: 10 },
reason: 'Missing required key: `window` and `filter`.',
},
{
example: { window: 600 },
reason: 'Missing required key: `limit` and `filter`.',
},
{
example: { filter: 'trial' },
reason: 'Missing required key: `window` and `limit`.',
},
{
example: {},
reason: 'Missing required keys: `window`, `limit`, and `filter`.',
},
],
additionalProperties: false,
});

0 comments on commit 46da867

Please sign in to comment.