Skip to content

Commit

Permalink
Clarify resource_exhausted description and fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
marioizquierdo committed Sep 15, 2020
1 parent b91c264 commit 4bc5632
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ depends upon the HTTP status of the invalid response:
| 401 Unauthorized | Unauthenticated
| 403 Forbidden | PermissionDenied
| 404 Not Found | BadRoute
| 429 Too Many Requests | Unavailable
| 429 Too Many Requests | ResourceExhausted
| 502 Bad Gateway | Unavailable
| 503 Service Unavailable | Unavailable
| 504 Gateway Timeout | Unavailable
Expand Down
2 changes: 1 addition & 1 deletion docs/spec_v7.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ corresponding HTTP Status Code for the response.
| already_exists | 409 | An attempt to create an entity failed because one already exists.
| permission_denied | 403 | The caller does not have permission to execute the specified operation. It must not be used if the caller cannot be identified (use "unauthenticated" instead).
| unauthenticated | 401 | The request does not have valid authentication credentials for the operation.
| resource_exhausted | 429 | Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space.
| resource_exhausted | 429 | Some resource has been exhausted or rate-limited, perhaps a per-user quota, or perhaps the entire file system is out of space.
| failed_precondition | 412 | The operation was rejected because the system is not in a state required for the operation's execution. For example, doing an rmdir operation on a directory that is non-empty, or on a non-directory object, or when having conflicting read-modify-write on the same resource.
| aborted | 409 | The operation was aborted, typically due to a concurrency issue like sequencer check failures, transaction aborts, etc.
| out_of_range | 400 | The operation was attempted past the valid range. For example, seeking or reading past end of a paginated collection. Unlike "invalid_argument", this error indicates a problem that may be fixed if the system state changes (i.e. adding more items to the collection). There is a fair bit of overlap between "failed_precondition" and "out_of_range". We recommend using "out_of_range" (the more specific error) when it applies so that callers who are iterating through a space can easily look for an "out_of_range" error to detect when they are done.
Expand Down
4 changes: 2 additions & 2 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ const (
// credentials for the operation.
Unauthenticated ErrorCode = "unauthenticated"

// ResourceExhausted indicates some resource has been exhausted, perhaps a
// per-user quota, or perhaps the entire file system is out of space.
// ResourceExhausted indicates some resource has been exhausted or rate-limited,
// perhaps a per-user quota, or perhaps the entire file system is out of space.
ResourceExhausted ErrorCode = "resource_exhausted"

// FailedPrecondition indicates operation was rejected because the system is
Expand Down
2 changes: 1 addition & 1 deletion protoc-gen-twirp/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ func (t *twirp) generateUtils() {
t.P(` code = `, t.pkgs["twirp"], `.BadRoute`)
t.P(` case 429: // Too Many Requests`)
t.P(` code = `, t.pkgs["twirp"], `.ResourceExhausted`)
t.P(` case 502, 503, 504: // Too Many Requests, Bad Gateway, Service Unavailable, Gateway Timeout`)
t.P(` case 502, 503, 504: // Bad Gateway, Service Unavailable, Gateway Timeout`)
t.P(` code = `, t.pkgs["twirp"], `.Unavailable`)
t.P(` default: // All other codes`)
t.P(` code = `, t.pkgs["twirp"], `.Unknown`)
Expand Down

0 comments on commit 4bc5632

Please sign in to comment.