Skip to content

Commit e590e61

Browse files
committed
chore: Update to types@4.0.0, workflow-support@4.0.0
1 parent 658fc36 commit e590e61

8 files changed

Lines changed: 104 additions & 203 deletions

File tree

activity-sleepy/wit/ext/tutorial_activity-obelisk-ext/activity-obelisk-ext.wit

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
// Generated by Obelisk 0.26.2
1+
// Generated by Obelisk 0.29.0
22
package tutorial:activity-obelisk-ext;
33

44
interface activity-sleepy {
5-
use obelisk:types/execution@3.0.0.{execution-id, join-set, await-next-extension-error, get-extension-error, invoke-extension-error};
5+
use obelisk:types/execution@4.0.0.{execution-id};
6+
use obelisk:types/join-set@4.0.0.{join-set};
7+
use obelisk:types/execution@4.0.0.{await-next-extension-error, get-extension-error, invoke-extension-error};
68

79
step-submit: func(join-set: borrow<join-set>, idx: u64, sleep-millis: u64) -> execution-id;
810

activity-sleepy/wit/ext/tutorial_activity-obelisk-schedule/activity-obelisk-schedule.wit

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// Generated by Obelisk 0.26.2
1+
// Generated by Obelisk 0.29.0
22
package tutorial:activity-obelisk-schedule;
33

44
interface activity-sleepy {
5-
use obelisk:types/execution@3.0.0.{execution-id};
6-
use obelisk:types/time@3.0.0.{schedule-at};
5+
use obelisk:types/execution@4.0.0.{execution-id};
6+
use obelisk:types/time@4.0.0.{schedule-at};
77

88
step-schedule: func(schedule-at: schedule-at, idx: u64, sleep-millis: u64) -> execution-id;
99
}

workflow-tutorial/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use exports::tutorial::workflow::workflow::Guest;
22
use obelisk::{
33
log::log,
44
types::time::{Duration, ScheduleAt},
5-
workflow::workflow_support::{self, ClosingStrategy, new_join_set_generated},
5+
workflow::workflow_support,
66
};
77
use tutorial::{
88
activity::activity_sleepy::step,
@@ -20,7 +20,7 @@ impl Guest for Component {
2020
let mut acc = 0;
2121
for i in 0..10 {
2222
log::info("Persistent sleep started");
23-
workflow_support::sleep(ScheduleAt::In(Duration::Seconds(1)));
23+
workflow_support::sleep(ScheduleAt::In(Duration::Seconds(1)))?;
2424
log::info("Persistent sleep finished");
2525
let result = step(i, i * 200).inspect_err(|_| log::error("step timed out"))?;
2626
acc += result;
@@ -35,7 +35,7 @@ impl Guest for Component {
3535
let max_iterations = 10;
3636
let mut handles = Vec::new();
3737
for i in 0..max_iterations {
38-
let join_set = new_join_set_generated(ClosingStrategy::Complete);
38+
let join_set = workflow_support::join_set_create();
3939
step_submit(&join_set, i, i * 200);
4040
handles.push((i, join_set));
4141
}
@@ -47,7 +47,7 @@ impl Guest for Component {
4747
let result = result.inspect_err(|_| log::error("step timed out"))?;
4848
acc = 10 * acc + result; // order-sensitive
4949
log::info(&format!("step({i})={result}, acc={acc}"));
50-
workflow_support::sleep(ScheduleAt::In(Duration::Milliseconds(300)));
50+
workflow_support::sleep(ScheduleAt::In(Duration::Milliseconds(300)))?;
5151
}
5252
log::info(&format!("parallel completed: {acc}"));
5353
Ok(acc)

workflow-tutorial/wit/deps/obelisk_types@3.0.0/types.wit

Lines changed: 0 additions & 108 deletions
This file was deleted.

webhook-tutorial/wit/deps/obelisk_types@3.0.0/types.wit renamed to workflow-tutorial/wit/deps/obelisk_types@4.0.0/types.wit

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package obelisk:types@3.0.0;
1+
package obelisk:types@4.0.0;
22

33
@since(version = 3.0.0)
44
interface time {
@@ -28,16 +28,9 @@ interface time {
2828
}
2929
}
3030

31-
@since(version = 3.0.0)
31+
@since(version = 4.0.0)
3232
interface execution {
3333

34-
/// Join set resouce.
35-
@since(version = 3.0.0)
36-
resource join-set {
37-
@since(version = 3.0.0)
38-
id: func() -> string;
39-
}
40-
4134
@since(version = 3.0.0)
4235
record execution-id {
4336
id: string,
@@ -106,3 +99,41 @@ interface execution {
10699
conflict,
107100
}
108101
}
102+
103+
104+
@since(version = 4.0.0)
105+
interface join-set {
106+
use time.{schedule-at};
107+
use execution.{delay-id, response-id};
108+
109+
/// Join set resouce.
110+
@since(version = 4.0.0)
111+
resource join-set {
112+
113+
/// Get the join set identifier in the form of:
114+
/// * `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,
115+
/// * `g:NAME` in case of a generated join set where `NAME` is generally an auto-incremented index,
116+
/// * `n:NAME` in case of a named join set
117+
@since(version = 4.0.0)
118+
id: func() -> string;
119+
120+
/// Submit a delay request to the join set. The delay can be later polled using `join-next`.
121+
@since(version = 4.0.0)
122+
submit-delay: func(timeout: schedule-at) -> delay-id;
123+
124+
/// Block the workflow execution until next response associated with the join set arrives.
125+
/// The response is marked as processed.
126+
/// Child execution result can be obtained using `-get` extension function using the
127+
/// returned execution ID.
128+
/// Return `join-next-error::all-processed` if the join set has all requests matched with responses.
129+
@since(version = 4.0.0)
130+
join-next: func() -> result<tuple<response-id, result>, join-next-error>;
131+
}
132+
133+
/// Error variants that may occur when calling `join-next` function.
134+
@since(version = 4.0.0)
135+
variant join-next-error {
136+
/// All submitted requests and their responses were already processed.
137+
all-processed,
138+
}
139+
}

workflow-tutorial/wit/deps/obelisk_workflow@3.0.0/workflow-support.wit

Lines changed: 0 additions & 75 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package obelisk:workflow@4.0.0;
2+
3+
@since(version = 4.0.0)
4+
interface workflow-support {
5+
use obelisk:types/time@4.0.0.{schedule-at, datetime};
6+
use obelisk:types/execution@4.0.0.{delay-id, execution-id, response-id};
7+
use obelisk:types/join-set@4.0.0.{join-set};
8+
9+
/// Error variants that may occur on named join set creation.
10+
@since(version = 3.0.0)
11+
variant join-set-create-error {
12+
conflict,
13+
invalid-name(string),
14+
}
15+
16+
/// Returns a random u64 in the range [min, max).
17+
@since(version = 3.0.0)
18+
random-u64: func(min: u64, max-exclusive: u64) -> u64;
19+
/// Returns a random u64 in the range [min, max].
20+
@since(version = 3.0.0)
21+
random-u64-inclusive: func(min: u64, max-inclusive: u64) -> u64;
22+
23+
/// Returns a random string with a length in the range [min_length, max_length).
24+
/// The string consists only of alphanumeric characters (lowercase and uppercase letters, digits).
25+
@since(version = 3.0.0)
26+
random-string: func(min-length: u16, max-length-exclusive: u16) -> string;
27+
28+
/// Block execution for given time, return the time when the durable sleep expires.
29+
/// Returns error if the delay is cancelled.
30+
@since(version = 4.0.0)
31+
sleep: func(schedule-at: schedule-at) -> result<datetime>;
32+
33+
/// Create a new join set with a generated name.
34+
@since(version = 4.0.0)
35+
join-set-create: func() -> join-set;
36+
37+
/// Create a new join set with the specified name.
38+
/// The name may only contain alphanumeric characters and the following extra characters:
39+
/// * underscore `_`
40+
/// * dash `-`
41+
/// * forward slash `/`
42+
@since(version = 4.0.0)
43+
join-set-create-named: func(name: string) -> result<join-set, join-set-create-error>;
44+
45+
/// Explicitly close join set. Unawaited delay requests are ignored,
46+
/// unawaited activities are cancelled, unawaited child workflows block
47+
/// until finish, as mandated by structured concurrency pattern.
48+
/// Extension function `-get` can be later used to lookup the execution result.
49+
@since(version = 4.0.0)
50+
join-set-close: func(self: join-set);
51+
}

workflow-tutorial/wit/impl.wit

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ world any {
77
// Generated extensions for `parallel` workflow.
88
import tutorial:activity-obelisk-ext/activity-sleepy;
99
// Obelisk SDK
10-
import obelisk:types/execution@3.0.0;
11-
import obelisk:workflow/workflow-support@3.0.0;
10+
import obelisk:types/execution@4.0.0;
11+
import obelisk:workflow/workflow-support@4.0.0;
1212
import obelisk:log/log@1.0.0;
1313
}

0 commit comments

Comments
 (0)