Requests an RTA spec makes fail, answer slowly or answer empty on purpose, so a spec can drive a screen's failure, slow-server and nothing-there paths against a server that is healthy, fast and full. Pure: the API coordinator holds the list and calls these from its own thread, and the only caller is compiled in under ENABLE_RTA (ApiQueueTask).
A spec writes rules to m.global.rtaFailRequests: { prefix: "itemQuery_usersItems", kind: "timeout" | "http" | "slow" | "empty", status: 500, ms: 20000, times: 1, after: 0 } A rule matches a request whose requestId starts with prefix. times is how many matching requests it applies to; without it, every one. after is how many matching requests it lets through first, for a request id that repeats too quickly for a spec to set the rule in between (a grid's page 1 and page 2).
A failed request is answered with the response the pool itself delivers for that failure. A slow one is sent, and its real answer is held until ms after it was sent, with its slot kept busy all that time: what a slow server costs the app, pool slot included. An empty one is answered as a server with nothing to give answers: ok, with an empty list in the shape its request expects. Nothing marks any of them as injected: code that could tell them apart could handle a test differently from the real thing, which is what these specs exist to catch.
- Source
Methods
(static) checkedRule(rule) → {dynamic}
| Name | Type | Description |
|---|---|---|
rule | dynamic |
- Source
- Type:
- dynamic
(static) fromRules(rules) → {object}
The rules a spec wrote, checked. A rule that cannot be honored exactly is dropped rather than guessed at, so a typo in a spec fails that spec's assertions instead of failing some other request.
| Name | Type | Description |
|---|---|---|
rules | dynamic | the value of m.global.rtaFailRequests |
- Source
an array of { prefix, kind, status, ms, remaining, passes }, remaining -1 meaning no limit
- Type:
- object
(static) isSlow(fault) → {boolean}
Whether fault delays a request rather than failing it.
| Name | Type | Description |
|---|---|---|
fault | object |
- Source
- Type:
- boolean
(static) isString(value) → {boolean}
| Name | Type | Description |
|---|---|---|
value | dynamic |
- Source
- Type:
- boolean
(static) nextWaitMs(held, nowMs) → {integer}
How long the coordinator may wait for its next event before a held answer is due: 0 (no limit, as wait() reads it) when nothing is held, and never less than 1 ms otherwise, since 0 would mean waiting forever past the due time.
| Name | Type | Description |
|---|---|---|
held | object | the held answers, each with |
nowMs | integer | the coordinator's clock now |
- Source
- Type:
- integer
(static) responseFor(fault, requestId, expectsListopt) → {object}
The pool's response for a request answered this way, the shape ApiTask.executeRequest builds. A timeout is what roku-requests returns when it gives up: not ok, and no status or body, because it only reads those from a response that arrived. An empty answer is ok with nothing in it: a bare [] for a list request (ApiClient.listReq), which ApiTask's shape check would otherwise demand, and an empty query result for any other.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
fault | object | |||
requestId | string | |||
expectsList | boolean | <optional> | false | the request declared a bare-array body (apiResponse.expectsList) |
- Source
- Type:
- object
(static) take(faults, requestId) → {dynamic}
The first fault that applies to requestId, counted as used; invalid when none does. Mutates faults: the caller keeps the list across requests.
A rule still letting requests through (after) claims each match and passes it, rather than handing it to a later rule: the spec asked for those requests to succeed.
| Name | Type | Description |
|---|---|---|
faults | object | |
requestId | string |
- Source
- Type:
- dynamic
(static) takeDue(held, nowMs) → {object}
The held answers that are due, taken out of held in the order they were held. Mutates held: the caller keeps the list across events.
| Name | Type | Description |
|---|---|---|
held | object | the held answers, each with |
nowMs | integer | the coordinator's clock now |
- Source
- Type:
- object
(static) wholeNumber(value) → {integer}
A number arrives with whatever numeric type the ODC write produced. -1 for anything else.
| Name | Type | Description |
|---|---|---|
value | dynamic |
- Source
- Type:
- integer