Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions schemas/1.0.0-Draft.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@
"$ref": "#/definitions/Period",
"description": "The period of the limit.",
"title": "period"
},
"type": {
"description": "Specifies how the API handles requests to the given endpoint, can be one of 'burst' or 'average'. The default value is 'burst'",
"enum": ["burst","average"],
"title": "type",
"type": "string",
"default": "burst"
}
},
"required": ["max"],
Expand Down
7 changes: 7 additions & 0 deletions versions/Working-Draft.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,18 @@ The allowed limits of the metric (e.g. *requests*).
| :------------- | :--------- | :------------|
| max | `number` | **Required** Maximum value that can be reached so the limit is not violated. |
| period | `string` | **Optional** The period specified for the given limit; it should be one of the following possible values: `second`, `minute`, `hour`, `day`, `month` or `year`. In case it is not specified, it would be a **permanent** limit over the metric. |
| type | `string` | **Optional** Specifies how the API handles requests to the given endpoint, can be one of `burst` or `average` (for further explanation see below). The default value is `burst`. |

The difference between `burst` and `average` is better explained with an example. Supposing an endpoint that allows 10 requests per minute:

- `average`: Would allow an average of 10 requests per minute, meaning only one request every 6 seconds would be accepted. Any other request received within these 6-second intervals would be rejected with HTTP code 429.
- `burst`: Would allow all 10 requests to be served at the any time during the minute. Once 10 requests have been served and until the end of the minute, all successive requests would be rejected with HTTP code 429.

**Example:**
```yaml
max: 2
period: second
type: burst
```

## References
Expand Down
9 changes: 3 additions & 6 deletions versions/samples/petstore/petstore-plans.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ plans:
requests:
- max: 1
period: second
type: average
pro:
pricing:
cost: 5
Expand All @@ -29,15 +30,11 @@ plans:
requests:
- max: 20
period: minute
scope: account
- max: 100
period: hour
scope: tenant
type: average
post:
requests:
- max: 100
period: minute
resourceInstances:
- max: 500
animalTypes:
- max: 5
type: burst
9 changes: 3 additions & 6 deletions versions/samples/petstore/pro-petstore-sla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,18 @@ plan:
requests:
- max: 20
period: minute
scope: account
type: burst
- max: 100
period: hour
scope: tenant
type: average
post:
requests:
- max: 100
period: minute
resourceInstances:
- max: 500
animalTypes:
- max: 5
rates:
/pets/{id}:
get:
requests:
- max: 3
period: second
type: average