Skip to content

Commit 9b93945

Browse files
authored
retries (#92)
1 parent 8dd3a48 commit 9b93945

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/Node.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ export type Options = {
1111
id?: Node["id"];
1212
/** When true the server will omit this node's output. Default: false */
1313
hide?: boolean;
14+
/** Number of seconds to cache an output for this node's unique inputs. Default: null */
15+
cache_age?: number;
16+
/** Applies if cache_age > 0. Optionally specify a subset of keys to use when computing a cache key.
17+
* Default: all node arguments
18+
*/
19+
cache_keys?: string[];
20+
/** Max number of times to retry this node if it fails. Default: null means no retries */
21+
max_retries?: number;
1422
};
1523

1624
export abstract class Node {
@@ -22,6 +30,14 @@ export abstract class Node {
2230
args: Object;
2331
/** When true the server will omit this node's output. Default: false */
2432
hide: boolean;
33+
/** Number of seconds to cache an output for this node's unique inputs. Default: null */
34+
cache_age?: number;
35+
/** Applies if cache_age > 0. Optionally specify a subset of keys to use when computing a cache key.
36+
* Default: all node arguments
37+
*/
38+
cache_keys?: string[];
39+
/** Max number of times to retry this node if it fails. Default: null means no retries */
40+
max_retries?: number;
2541

2642
/** TODO this field stores the last response, but it's just temporary until the internals are refactored */
2743
protected _response: SubstrateResponse | undefined;
@@ -31,6 +47,9 @@ export abstract class Node {
3147
this.args = args;
3248
this.id = opts?.id || generator(this.node);
3349
this.hide = opts?.hide || false;
50+
this.cache_age = opts?.cache_age;
51+
this.cache_keys = opts?.cache_keys;
52+
this.max_retries = opts?.max_retries;
3453
}
3554

3655
/**
@@ -103,6 +122,9 @@ export abstract class Node {
103122
node: this.node,
104123
args: withPlaceholders(this.args),
105124
_should_output_globally: !this.hide,
125+
...(this.cache_age && { _cache_age: this.cache_age }),
126+
...(this.cache_keys && { _cache_keys: this.cache_keys }),
127+
...(this.max_retries && { _max_retries: this.max_retries }),
106128
};
107129
}
108130

0 commit comments

Comments
 (0)