Skip to content

Commit 3934057

Browse files
authored
Add Nexus-Request-Retryable header, line wrap spec (#15)
1 parent 94d950f commit 3934057

File tree

2 files changed

+43
-34
lines changed

2 files changed

+43
-34
lines changed

Diff for: SPEC.md

+38-32
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ The Nexus protocol, as specified below, is a synchronous RPC protocol. Arbitrary
66
of a set of pre-defined synchronous RPCs.
77

88
A Nexus **caller** calls a **handler**. The handler may respond inline or return a reference for a future, asynchronous
9-
operation. The caller can cancel an asynchronous operation, check for its outcome, or fetch its current state. The caller
10-
can also specify a callback URL, which the handler uses to asynchronously deliver the result of an operation when it
11-
is ready.
9+
operation. The caller can cancel an asynchronous operation, check for its outcome, or fetch its current state. The
10+
caller can also specify a callback URL, which the handler uses to asynchronously deliver the result of an operation when
11+
it is ready.
1212

1313
## Operation Addressability
1414

@@ -76,18 +76,17 @@ properties:
7676

7777
### Start Operation
7878

79-
Start an arbitrary length operation.
80-
The response of the operation may be delivered synchronously (inline), or asynchronously, via a provided callback or the
81-
[Get Operation Result](#get-operation-result) endpoint.
79+
Start an arbitrary length operation. The response of the operation may be delivered synchronously (inline), or
80+
asynchronously, via a provided callback or the [Get Operation Result](#get-operation-result) endpoint.
8281

8382
**Path**: `/{service}/{operation}`
8483

8584
**Method**: `POST`
8685

8786
#### Query Parameters
8887

89-
- `callback`: Optional. If the operation is asynchronous, the handler should invoke this URL once the operation's
90-
result is available.
88+
- `callback`: Optional. If the operation is asynchronous, the handler should invoke this URL once the operation's result
89+
is available.
9190

9291
#### Request Headers
9392

@@ -148,10 +147,8 @@ The body may contain arbitrary data. Headers should specify content type and enc
148147

149148
### Cancel Operation
150149

151-
Request to cancel an operation.
152-
The operation may later complete as canceled or any other outcome.
153-
Handlers should ignore multiple cancelations of the same operation and return successfully if cancelation was already
154-
requested.
150+
Request to cancel an operation. The operation may later complete as canceled or any other outcome. Handlers should
151+
ignore multiple cancelations of the same operation and return successfully if cancelation was already requested.
155152

156153
**Path**: `/{service}/{operation}/{operation_id}/cancel`
157154

@@ -181,9 +178,8 @@ Retrieve operation result.
181178

182179
#### Query Parameters
183180

184-
- `wait`: Optional. Duration indicating the waiting period for a result, defaulting to no wait.
185-
If by the end of the wait period the operation is still running, the request should resolve with a 412 status code
186-
(see below).
181+
- `wait`: Optional. Duration indicating the waiting period for a result, defaulting to no wait. If by the end of the
182+
wait period the operation is still running, the request should resolve with a 412 status code (see below).
187183

188184
Format of this parameter is number + unit, where unit can be `ms` for milliseconds, `s` for seconds, and `m` for
189185
minutes. Examples:
@@ -262,17 +258,20 @@ Retrieve operation details.
262258
For compatiblity of this HTTP spec with future transports, when a handler fails a request, it **should** use one of the
263259
following predefined error codes.
264260

265-
| Name | Status Code | Description |
266-
| -------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------- |
267-
| `BAD_REQUEST` | 400 | The server cannot or will not process the request due to an apparent client error. |
268-
| `UNAUTHENTICATED` | 401 | The client did not supply valid authentication credentials for this request. |
269-
| `UNAUTHORIZED` | 403 | The caller does not have permission to execute the specified operation. |
270-
| `NOT_FOUND` | 404 | The requested resource could not be found but may be available in the future. Subsequent requests by the client are permissible. |
271-
| `RESOURCE_EXHAUSTED` | 429 | Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. |
272-
| `INTERNAL` | 500 | An internal error occured. |
273-
| `NOT_IMPLEMENTED` | 501 | The server either does not recognize the request method, or it lacks the ability to fulfill the request. |
274-
| `UNAVAILABLE` | 503 | The service is currently unavailable. |
275-
| `UPSTREAM_TIMEOUT` | 520 | Used by gateways to report that a request to an upstream server has timed out. |
261+
| Name | Status Code | Description |
262+
| -------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
263+
| `BAD_REQUEST` | 400 | The server cannot or will not process the request due to an apparent client error. Clients should not retry this request unless advised otherwise. |
264+
| `UNAUTHENTICATED` | 401 | The client did not supply valid authentication credentials for this request. Clients should not retry this request unless advised otherwise. |
265+
| | | |
266+
| `UNAUTHORIZED` | 403 | The caller does not have permission to execute the specified operation. Clients should not retry this request unless advised otherwise. |
267+
| | | |
268+
| `NOT_FOUND` | 404 | The requested resource could not be found but may be available in the future. Subsequent requests by the client are permissible but not advised. |
269+
| | | |
270+
| `RESOURCE_EXHAUSTED` | 429 | Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. Subsequent requests by the client are permissible. |
271+
| `INTERNAL` | 500 | An internal error occured. Clients should not retry this request unless advised otherwise. |
272+
| `NOT_IMPLEMENTED` | 501 | The server either does not recognize the request method, or it lacks the ability to fulfill the request. Clients should not retry this request unless advised otherwise. |
273+
| `UNAVAILABLE` | 503 | The service is currently unavailable. Subsequent requests by the client are permissible. |
274+
| `UPSTREAM_TIMEOUT` | 520 | Used by gateways to report that a request to an upstream server has timed out. Subsequent requests by the client are permissible. |
276275

277276
## General Purpose Headers
278277

@@ -285,7 +284,14 @@ Handlers and callers can specify links in different Nexus requests to associate
285284

286285
Links must contain a `type` parameter that expresses how they should be parsed.
287286

288-
**Example**: `Nexus-Link: <myscheme://somepath?k=v>; type="com.example.MyResource"
287+
**Example**: `Nexus-Link: <myscheme://somepath?k=v>; type="com.example.MyResource"`
288+
289+
### `Nexus-Request-Retryable`
290+
291+
Handlers may specify the `Nexus-Request-Retryable` header to explicitly instruct a caller whether or not to retry a
292+
request. Unless specified, retry behavior is determined from the
293+
[predefined handler error type](#predefined-handler-errors). For example `INTERNAL` errors is not retryable by default
294+
unless specified otherwise.
289295

290296
### `Request-Timeout`
291297

@@ -308,8 +314,9 @@ For invoking a callback URL:
308314
prefix.
309315
- Include the `Nexus-Operation-Id` header, `Nexus-Operation-Start-Time` and any `Nexus-Link` headers for resources
310316
associated with this operation to support completing asynchronous operations before the response to StartOperation is
311-
received. `Nexus-Operation-Start-Time` should be in a valid HTTP format described [here](https://www.rfc-editor.org/rfc/rfc5322.html#section-3.3).
312-
If is omitted, the time the completion is received will be used as operation start time.
317+
received. `Nexus-Operation-Start-Time` should be in a valid HTTP format described
318+
[here](https://www.rfc-editor.org/rfc/rfc5322.html#section-3.3). If is omitted, the time the completion is received
319+
will be used as operation start time.
313320
- Include the `Nexus-Operation-State` header.
314321
- If state is `succeeded`, deliver non-empty results in the body with corresponding `Content-*` headers.
315322
- If state is `failed` or `canceled`, content type should be `application/json` and the body must have a serialized
@@ -319,9 +326,8 @@ For invoking a callback URL:
319326
### Security
320327

321328
There's no enforced security for callback URLs at this time. However, some specific Nexus server implementations may
322-
deliver additional details as headers or have other security requirements of the callback endpoint.
323-
When starting an operation, callers may embed a signed token into the URL, which can be verified upon delivery of
324-
completion.
329+
deliver additional details as headers or have other security requirements of the callback endpoint. When starting an
330+
operation, callers may embed a signed token into the URL, which can be verified upon delivery of completion.
325331

326332
[rfc3986-section-2.3]: https://datatracker.ietf.org/doc/html/rfc3986#section-2.3
327333

Diff for: dprint.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
2-
"markdown": {},
2+
"markdown": {
3+
"lineWidth": 120,
4+
"textWrap": "always"
5+
},
36
"includes": ["*.md"],
47
"excludes": [],
5-
"plugins": ["https://plugins.dprint.dev/markdown-0.15.3.wasm"]
8+
"plugins": ["https://plugins.dprint.dev/markdown-0.17.8.wasm"]
69
}

0 commit comments

Comments
 (0)