Skip to content

Commit

Permalink
brownout policy docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ntotten committed Nov 2, 2023
1 parent a3a70b7 commit d23f832
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 52 deletions.
51 changes: 0 additions & 51 deletions policies/brown-out-inbound/schema.json

This file was deleted.

File renamed without changes
12 changes: 12 additions & 0 deletions policies/brownout-inbound/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
The brownout policy allows performing scheduled downtime on your API. This can
be useful for helping notify clients of an impending deprecation or for
scheduling maintenance.

This policy uses [cron schedules](https://crontab.guru/) to check if a request
should experience a brownout or not. When a request falls into a scheduled
brownout an error response will be return. The error response can be customized
by setting the `problem` properties.

For more information using brownouts to alert clients on impending API
changes/deprecations see our blog post
[How to version an API](https://zuplo.com/blog/2022/05/17/how-to-version-an-api)
74 changes: 74 additions & 0 deletions policies/brownout-inbound/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$id": "http://zuplo.com/schemas/policies/brown-out-inbound.json",
"type": "object",
"title": "Brown Out",
"description": "Set periods of downtime based on cron schedules. Useful for alerting users of impending deprecations.",
"required": ["handler"],
"properties": {
"handler": {
"type": "object",
"default": {},
"required": ["export", "module", "options"],
"properties": {
"export": {
"const": "BrownOutInbound",
"description": "The name of the exported type"
},
"module": {
"const": "$import(@zuplo/runtime)",
"description": "The module containing the policy"
},
"options": {
"type": "object",
"description": "The options for this policy",
"required": ["cronSchedule"],
"properties": {
"cronSchedule": {
"oneOf": [
{ "type": "string" },
{ "type": "array", "item": { "type": "string" } }
],
"description": "The cron schedule for when this policy is enabled. This can be a single cron string or an array of multiple cron strings"
},
"problem": {
"type": "object",
"description": "The problem that is returned in the response body when this policy is enabled",
"additionalProperties": true,
"properties": {
"type": {
"type": "string",
"description": "The type of problem"
},
"title": {
"type": "string",
"description": "The title of problem"
},
"detail": {
"type": "string",
"description": "The detail of problem"
},
"status": {
"type": "number",
"description": "Http status code of the problem"
}
}
}
}
}
},
"examples": [
{
"export": "BrownOutInbound",
"module": "$import(@zuplo/runtime)",
"options": {
"cronSchedule": "0 23 * * *",
"problem": {
"detail": "This endpoint is deprecated and will be removed in the next version"
}
}
}
]
}
}
}
2 changes: 1 addition & 1 deletion scripts/update-policies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ sidebar_label: ${schema.title}
${
schema.isCustom
? `<CustomPolicyNotice name="${schema.title}" id="${policyId}" />`
: null
: ""
}
<!-- start: intro.md -->
Expand Down
1 change: 1 addition & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ const sidebars = {
label: "Other",
items: [
"policies/composite-inbound",
"policies/brownout-inbound",
"policies/caching-inbound",
"policies/archive-request-inbound",
"policies/archive-response-outbound",
Expand Down
5 changes: 5 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,11 @@
"source": "/docs/articles/supabase-auth{/}?",
"destination": "/docs/articles/dev-portal-supabase-auth",
"permanent": true
},
{
"source": "/docs/policies/brown-out-inbound{/}?",
"destination": "/docs/policies/brownout-inbound",
"permanent": true
}
],
"headers": [
Expand Down

1 comment on commit d23f832

@vercel
Copy link

@vercel vercel bot commented on d23f832 Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./

docs.zuplo.site
docs.zuplopreview.net
docs-git-main.zuplopreview.net

Please sign in to comment.