Skip to content

Commit 51d2653

Browse files
committed
chore: Add 4.1.0 types and workflow-support
1 parent 9cb0397 commit 51d2653

2 files changed

Lines changed: 267 additions & 0 deletions

File tree

wit/obelisk_types@4.1.0/types.wit

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
package obelisk:types@4.1.0;
2+
3+
@since(version = 3.0.0)
4+
interface time {
5+
6+
@since(version = 3.0.0)
7+
variant duration {
8+
milliseconds(u64),
9+
seconds(u64),
10+
minutes(u32),
11+
hours(u32),
12+
days(u32),
13+
}
14+
15+
/// A time and date in seconds plus nanoseconds.
16+
// Extracted from wasi:clocks@0.2.0 to avoid dependency on wasi:io
17+
@since(version = 3.0.0)
18+
record datetime {
19+
seconds: u64,
20+
nanoseconds: u32,
21+
}
22+
23+
@since(version = 3.0.0)
24+
variant schedule-at {
25+
now,
26+
at(datetime),
27+
in(duration),
28+
}
29+
}
30+
31+
@since(version = 4.0.0)
32+
interface execution {
33+
use time.{duration};
34+
35+
@since(version = 3.0.0)
36+
record execution-id {
37+
id: string,
38+
}
39+
40+
@since(version = 3.0.0)
41+
record delay-id {
42+
id: string,
43+
}
44+
45+
@since(version = 3.0.0)
46+
record function {
47+
// `namespace:pkg_name/ifc_name` or `namespace:pkg_name/ifc_name@version`
48+
interface-name: string,
49+
// must not contain dot (`.`)
50+
function-name: string,
51+
}
52+
53+
@since(version = 3.0.0)
54+
variant response-id {
55+
execution-id(execution-id),
56+
delay-id(delay-id),
57+
}
58+
59+
@since(version = 3.0.0)
60+
record function-mismatch {
61+
/// Workflow requested function
62+
specified-function: function,
63+
/// What was found actually during execution. None if delay was found as next unprocessed response.
64+
actual-function: option<function>,
65+
actual-id: response-id,
66+
}
67+
68+
/// Error that is thrown by `-await-next` extension functions.
69+
@since(version = 3.0.0)
70+
variant await-next-extension-error {
71+
/// All submitted requests and their responses of specified function and join set were already processed.
72+
all-processed,
73+
/// Execution response was awaited and marked as processed, but it belongs to a different function.
74+
/// This can happen when join set contains responses of multiple functions or delay requests.
75+
function-mismatch(function-mismatch),
76+
}
77+
78+
/// Error variants that may occur when calling `-get` extension functions.
79+
@since(version = 3.0.0)
80+
variant get-extension-error {
81+
/// Execution is found in processed responses, but it belongs to a different function.
82+
/// This can happen when join set contains responses of multiple functions.
83+
function-mismatch(function-mismatch),
84+
/// Processed responses do not contain the specified execution ID.
85+
/// Execution was not awaited using `-await-next` extension or `join-set.join-next`.
86+
not-found-in-processed-responses,
87+
}
88+
89+
/// Error variants that may occur when calling `-invoke` extension functions.
90+
@since(version = 3.0.0)
91+
// deprecated
92+
variant invoke-extension-error {
93+
invalid-name(string),
94+
}
95+
96+
/// Error variants that may occur when calling `-stub` extension functions.
97+
@since(version = 3.0.0)
98+
variant stub-error {
99+
/// Conflict can happen when a second writer attempts to stub a value, while the
100+
/// value is not equal to the already stubbed value.
101+
conflict,
102+
}
103+
104+
@since(version = 4.1.0)
105+
record submit-config {
106+
/// Override max duration of a execution run (single attempt).
107+
/// Applies to activities only as workflows automatically extend their locks using `lock_extension` setting.
108+
timeout: option<duration>,
109+
// TODO: add `max-retries`, `retry_exp_backoff`
110+
}
111+
}
112+
113+
114+
@since(version = 4.0.0)
115+
interface join-set {
116+
use time.{schedule-at};
117+
use execution.{delay-id, response-id};
118+
119+
/// Join set resouce.
120+
@since(version = 4.0.0)
121+
resource join-set {
122+
123+
/// Get the join set identifier in the form of:
124+
/// * `o:NAME` in case of a one-off join set, where `NAME` is generally an auto-incremented index optionally followed by underscode and a supplied name,
125+
/// * `g:NAME` in case of a generated join set where `NAME` is generally an auto-incremented index,
126+
/// * `n:NAME` in case of a named join set
127+
@since(version = 4.0.0)
128+
id: func() -> string;
129+
130+
/// Submit a delay request to the join set. The delay can be later polled using `join-next`.
131+
/// This function has been moved to `workflow-support`.
132+
@since(version = 4.0.0)
133+
@deprecated(version = 4.1.0)
134+
submit-delay: func(timeout: schedule-at) -> delay-id;
135+
136+
/// Block the workflow execution until next response associated with the join set arrives.
137+
/// The response is marked as processed.
138+
/// Child execution result can be obtained using `-get` extension function using the
139+
/// returned execution ID.
140+
/// Return `join-next-error::all-processed` if the join set has all requests matched with responses.
141+
/// This function has been moved to `workflow-support`.
142+
@since(version = 4.0.0)
143+
@deprecated(version = 4.1.0)
144+
join-next: func() -> result<tuple<response-id, result>, join-next-error>;
145+
}
146+
147+
/// Error variants that may occur when calling `join-next` function.
148+
@since(version = 4.0.0)
149+
@deprecated(version = 4.1.0)
150+
variant join-next-error {
151+
/// All submitted requests and their responses were already processed.
152+
all-processed,
153+
}
154+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package obelisk:workflow@4.1.0;
2+
3+
@since(version = 4.0.0)
4+
interface workflow-support {
5+
use obelisk:types/time@4.1.0.{schedule-at, datetime};
6+
use obelisk:types/execution@4.1.0.{delay-id, execution-id, response-id, function, submit-config};
7+
use obelisk:types/join-set@4.1.0.{join-set};
8+
9+
/// Error variants that may occur on named join set creation.
10+
/// The name may only contain alphanumeric characters and the following extra characters:
11+
/// * dash `-`
12+
/// * forward slash `/`
13+
@since(version = 3.0.0)
14+
variant join-set-create-error {
15+
conflict,
16+
invalid-name(string),
17+
}
18+
19+
@since(version = 4.1.0)
20+
variant get-result-json-error {
21+
execution-id-parsing-error(string),
22+
/// Processed responses do not contain the specified execution ID.
23+
/// Execution was not awaited using `-await-next` extension or `join-set.join-next`.
24+
not-found-in-processed-responses,
25+
}
26+
27+
@since(version = 4.1.0)
28+
variant submit-json-error {
29+
/// See `Function` definition
30+
ffqn-parsing-error(string),
31+
function-not-found,
32+
params-parsing-error(string),
33+
}
34+
35+
/// Error variants that may occur when calling `join-next` function.
36+
@since(version = 4.1.0)
37+
variant join-next-error {
38+
/// All submitted requests and their responses were already processed.
39+
all-processed,
40+
}
41+
42+
/// Error variants that may occur when calling `join-next-try` function.
43+
@since(version = 4.1.0)
44+
variant join-next-try-error {
45+
/// All submitted requests and their responses were already processed.
46+
all-processed,
47+
/// No response is available yet, but there are pending requests.
48+
pending,
49+
}
50+
51+
/// Returns a random u64 in the range [min, max).
52+
@since(version = 3.0.0)
53+
random-u64: func(min: u64, max-exclusive: u64) -> u64;
54+
/// Returns a random u64 in the range [min, max].
55+
@since(version = 3.0.0)
56+
random-u64-inclusive: func(min: u64, max-inclusive: u64) -> u64;
57+
58+
/// Returns a random string with a length in the range [min_length, max_length).
59+
/// The string consists only of alphanumeric characters (lowercase and uppercase letters, digits).
60+
@since(version = 3.0.0)
61+
random-string: func(min-length: u16, max-length-exclusive: u16) -> string;
62+
63+
/// Block execution for given time, return the time when the durable sleep expires.
64+
/// Returns error if the delay is cancelled.
65+
@since(version = 4.0.0)
66+
sleep: func(schedule-at: schedule-at) -> result<datetime>;
67+
68+
/// Create a new join set with a generated name.
69+
@since(version = 4.0.0)
70+
join-set-create: func() -> join-set;
71+
72+
/// Create a new join set with the specified name.
73+
/// The name may only contain alphanumeric characters and the following extra characters:
74+
/// * dash `-`
75+
/// * forward slash `/`
76+
@since(version = 4.0.0)
77+
join-set-create-named: func(name: string) -> result<join-set, join-set-create-error>;
78+
79+
/// Explicitly close join set. Unawaited delay requests are ignored,
80+
/// unawaited activities are cancelled, unawaited child workflows block
81+
/// until finish, as mandated by structured concurrency pattern.
82+
/// Extension function `-get` can be later used to lookup the execution result.
83+
@since(version = 4.0.0)
84+
join-set-close: func(self: join-set);
85+
86+
/// Submit a child execution request with its parameters serialized as JSON array to a join set.
87+
@since(version = 4.1.0)
88+
submit-json: func(join-set: borrow<join-set>, function: function, params: string, config: option<submit-config>) -> result<execution-id, submit-json-error>;
89+
90+
/// Obtain child execution result after it has been awaited using `-await-next` extension or `join-set.join-next`.
91+
@since(version = 4.1.0)
92+
get-result-json: func(execution-id: execution-id) -> result<result<option<string>, option<string>>, get-result-json-error>;
93+
94+
/// Submit a delay request to the join set. The delay can be later polled using `join-next`.
95+
@since(version = 4.1.0)
96+
submit-delay: func(join-set: borrow<join-set>, timeout: schedule-at) -> delay-id;
97+
98+
/// Block the workflow execution until next response associated with the join set arrives.
99+
/// The response is marked as processed.
100+
/// Child execution result can be obtained using `-get` extension function using the
101+
/// returned execution ID.
102+
/// Return `join-next-error::all-processed` if the join set has all requests matched with responses already processed.
103+
@since(version = 4.1.0)
104+
join-next: func(join-set: borrow<join-set>) -> result<tuple<response-id, result>, join-next-error>;
105+
106+
/// Attempt to process next response without blocking.
107+
/// Child execution result can be obtained using `-get` extension function using the
108+
/// returned execution ID.
109+
/// Return `join-next-try-error::all-processed` if the join set has all requests matched with responses already processed.
110+
/// Return `join-next-try-error::pending` if no response is available yet, but there are pending requests.
111+
@since(version = 4.1.0)
112+
join-next-try: func(join-set: borrow<join-set>) -> result<tuple<response-id, result>, join-next-try-error>;
113+
}

0 commit comments

Comments
 (0)