Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dev-deps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cargo-edit-upgrade 0.13.11
cargo-expand 1.0.123
cargo generate 0.23.9
just 1.55.1
obelisk 0.39.5
obelisk 0.40.0
pkg-config 0.29.2
rustc 1.96.0 (ac68faa20 2026-05-25)
wasm-tools 1.252.0
wasm-tools 1.253.0
ldd (GNU libc) 2.42
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Generated by Obelisk 0.36.0
// Generated by Obelisk 0.40.0
package tutorial:activity-obelisk-ext;

interface activity-sleepy {
use obelisk:types/execution@4.2.0.{execution-id};
use obelisk:types/join-set@4.2.0.{join-set};
use obelisk:types/execution@4.2.0.{await-next-extension-error, get-extension-error};
use obelisk:types/execution@5.0.0.{execution-id};
use obelisk:types/join-set@5.0.0.{join-set};
use obelisk:types/execution@5.0.0.{await-next-extension-error, get-extension-error};

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

step-await-next: func(join-set: borrow<join-set>) -> result<tuple<execution-id, result<u64>>, await-next-extension-error>;
step-await-next: func(join-set: borrow<join-set>) -> result<result<u64>, await-next-extension-error>;

step-get: func(execution-id: execution-id) -> result<result<u64>, get-extension-error>;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Generated by Obelisk 0.36.0
// Generated by Obelisk 0.40.0
package tutorial:activity-obelisk-schedule;

interface activity-sleepy {
use obelisk:types/execution@4.2.0.{execution-id};
use obelisk:types/time@4.2.0.{schedule-at};
use obelisk:types/execution@5.0.0.{execution-id};
use obelisk:types/time@5.0.0.{schedule-at};

step-schedule: func(schedule-at: schedule-at, idx: u64, sleep-millis: u64) -> execution-id;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package obelisk:types@4.2.0;
package obelisk:types@5.0.0;

@since(version = 3.0.0)
interface time {
Expand Down Expand Up @@ -28,8 +28,6 @@ interface time {
}
@since(version = 4.0.0)
interface execution {
use time.{duration};

@since(version = 3.0.0)
record execution-id {
id: string,
Expand Down Expand Up @@ -63,6 +61,18 @@ interface execution {
actual-id: response-id,
}

/// The kind of a platform-level execution failure, as opposed to a business
/// `err` result. Surfaced additively via `get-execution-failure-kind`; the
/// err value itself keeps carrying the `execution-failed` sentinel.
@since(version = 5.0.0)
enum execution-failure-kind {
timed-out,
nondeterminism-detected,
out-of-fuel,
cancelled,
uncategorized,
}

/// Error that is thrown by `-await-next` extension functions.
@since(version = 3.0.0)
variant await-next-extension-error {
Expand All @@ -84,13 +94,6 @@ interface execution {
not-found-in-processed-responses,
}

/// Error variants that may occur when calling `-invoke` extension functions.
@since(version = 3.0.0)
// deprecated
variant invoke-extension-error {
invalid-name(string),
}

/// Error variants that may occur when calling `-stub` extension functions.
@since(version = 3.0.0)
variant stub-error {
Expand All @@ -103,14 +106,6 @@ interface execution {
conflict,
}

@since(version = 4.1.0)
record submit-config {
/// Override max duration of a execution run (single attempt).
/// Applies to activities only as workflows automatically extend their locks using `lock_extension` setting.
timeout: option<duration>,
// TODO: add `max-retries`, `retry_exp_backoff`
}

@since(version = 4.2.0)
variant schedule-json-error {
/// See `Function` definition
Expand Down Expand Up @@ -145,8 +140,7 @@ interface backtrace {

@since(version = 4.0.0)
interface join-set {
use time.{schedule-at};
use execution.{delay-id, response-id};
use execution.{response-id};

/// Join set resouce.
@since(version = 4.0.0)
Expand All @@ -159,28 +153,12 @@ interface join-set {
@since(version = 4.0.0)
id: func() -> string;

/// Submit a delay request to the join set. The delay can be later polled using `join-next`.
/// This function has been moved to `workflow-support`.
@since(version = 4.0.0)
@deprecated(version = 4.1.0)
submit-delay: func(timeout: schedule-at) -> delay-id;

/// Block the workflow execution until next response associated with the join set arrives.
/// The response is marked as processed.
/// Child execution result can be obtained using `-get` extension function using the
/// returned execution ID.
/// Return `join-next-error::all-processed` if the join set has all requests matched with responses.
/// This function has been moved to `workflow-support`.
@since(version = 4.0.0)
@deprecated(version = 4.1.0)
join-next: func() -> result<tuple<response-id, result>, join-next-error>;
}

/// Error variants that may occur when calling `join-next` function.
@since(version = 4.0.0)
@deprecated(version = 4.1.0)
variant join-next-error {
/// All submitted requests and their responses were already processed.
all-processed,
/// The `response-id` of the last processed response of this join set
/// (the one returned by the most recent `join-next` / `-await-next`),
/// or `none` if no response has been processed yet.
/// Must be read immediately after `join-next`, before the next one.
/// An `execution-id` marks a child response; a `delay-id` marks a delay.
@since(version = 5.0.0)
last-id: func() -> option<response-id>;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package obelisk:webhook@6.0.0;

@since(version = 5.0.0)
interface webhook-support {
use obelisk:types/time@5.0.0.{schedule-at, datetime};
use obelisk:types/execution@5.0.0.{execution-id, function, schedule-json-error, execution-failure-kind};

/// Error variants that may occur when calling `get-status`.
@since(version = 5.0.0)
variant get-status-error {
/// Cannot parse the execution ID.
execution-id-parsing-error(string),
/// The execution was not found.
not-found,
}

/// Error variants that may occur when calling `get`.
@since(version = 5.0.0)
variant get-error {
/// Cannot parse the execution ID.
execution-id-parsing-error(string),
/// The execution was not found.
not-found,
}

/// Error variants that may occur when calling `try-get`.
@since(version = 5.0.0)
variant try-get-error {
/// Cannot parse the execution ID.
execution-id-parsing-error(string),
/// The execution was not found.
not-found,
/// The execution has not finished yet.
not-finished-yet,
}

/// The status of an execution, including cancellation.
@since(version = 6.0.0)
variant execution-status {
/// Execution is scheduled to run at a specific time.
pending-at(datetime),
/// Execution is currently being processed.
locked,
/// Execution is currently paused.
paused,
/// Execution is waiting for child executions to complete (workflows only).
blocked-by-join-set,
/// Cancellation has been requested; the execution is being torn down.
cancelling,
/// Execution has finished.
finished(execution-status-finished),
}

/// The finished status of an execution.
@since(version = 6.0.0)
variant execution-status-finished {
/// Execution has finished with a successful result.
ok,
/// Execution has finished with an error result (user-level error).
err,
/// Execution has terminated due to an execution failure (system-level error).
execution-failure(execution-failure-kind),
}

/// Generate a new top-level execution ID.
@since(version = 5.0.0)
execution-id-generate: func() -> execution-id;

/// Get the execution ID of the current webhook handler invocation.
/// Returns the ID assigned to this webhook execution by the engine.
@since(version = 5.2.0)
execution-id-current: func() -> execution-id;


/// Call a function and wait for the result.
/// Creates a child execution, waits for it to complete, and returns the result.
/// Parameters are serialized as a JSON array.
/// Returns Ok(Some(json)) for successful result with value,
/// Ok(None) for successful result with no value,
/// Err(Some(json)) for error result with value,
/// Err(None) for error result with no value.
@since(version = 5.0.0)
call-json: func(function: function, params: string) -> result<result<option<string>, option<string>>, schedule-json-error>;

/// Schedule a new top-level execution with its parameters serialized as JSON array.
/// Use the execution ID returned by `execution-id-generate`.
@since(version = 5.0.0)
schedule-json: func(execution-id: execution-id, schedule-at: schedule-at, function: function, params: string) -> result<_, schedule-json-error>;

/// Get the current status of an execution.
/// Reports the `cancelling` state for cancellable workflows.
@since(version = 6.0.0)
get-status: func(execution-id: execution-id) -> result<execution-status, get-status-error>;

/// The kind of platform-level execution failure for a previously *processed*
/// child response (via `call-json` / `get` / `try-get`), or `none` if it
/// finished with an ok / business `err` result. Additive to the err value.
/// Errors the same way as `get` for an unknown or unfinished execution.
@since(version = 6.0.0)
get-execution-failure-kind: func(execution-id: execution-id) -> result<option<execution-failure-kind>, get-error>;

/// The execution ID of the last direct call (`call-json`), or `none` if there
/// was none. Pair with `get-execution-failure-kind` to resolve its failure kind.
@since(version = 6.0.0)
last-direct-call-id: func() -> option<execution-id>;

/// Get the result of an execution, blocking until it finishes.
/// Returns Ok(Some(json)) for successful result with value,
/// Ok(None) for successful result with no value,
/// Err(Some(json)) for error result with value,
/// Err(None) for error result with no value.
/// Outer result indicates lookup success/failure.
@since(version = 5.0.0)
get: func(execution-id: execution-id) -> result<result<option<string>, option<string>>, get-error>;

/// Try to get the result of an execution without blocking.
/// Returns immediately if the execution has finished, or `not-finished-yet` error otherwise.
/// Returns Ok(Some(json)) for successful result with value,
/// Ok(None) for successful result with no value,
/// Err(Some(json)) for error result with value,
/// Err(None) for error result with no value.
/// Outer result indicates lookup success/failure.
@since(version = 5.0.0)
try-get: func(execution-id: execution-id) -> result<result<option<string>, option<string>>, try-get-error>;
}

/// Backtrace-carrying variants of the event-persisting `webhook-support` functions.
/// Only interpreted runtimes (the JS runtime) supply a source-level `backtrace`;
/// native components import the plain `webhook-support` interface instead.
@since(version = 6.0.0)
interface webhook-support-backtrace {
use obelisk:types/time@5.0.0.{schedule-at};
use obelisk:types/execution@5.0.0.{execution-id, function, schedule-json-error};
use obelisk:types/backtrace@5.0.0.{wasm-backtrace};

/// See `webhook-support.call-json`.
@since(version = 6.0.0)
call-json: func(function: function, params: string, backtrace: option<wasm-backtrace>) -> result<result<option<string>, option<string>>, schedule-json-error>;

/// See `webhook-support.schedule-json`.
@since(version = 6.0.0)
schedule-json: func(execution-id: execution-id, schedule-at: schedule-at, function: function, params: string, backtrace: option<wasm-backtrace>) -> result<_, schedule-json-error>;
}
9 changes: 4 additions & 5 deletions rust/workflow-tutorial/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Guest for Component {
let mut acc = 0;
for i in 0..10 {
log::info("Persistent sleep started");
workflow_support::sleep_bt(ScheduleAt::In(Duration::Seconds(1)), None)?;
workflow_support::sleep(ScheduleAt::In(Duration::Seconds(1)), None)?;
log::info("Persistent sleep finished");
let result = step(i, i * 200).inspect_err(|_| log::error("step timed out"))?;
acc += result;
Expand All @@ -35,19 +35,18 @@ impl Guest for Component {
let max_iterations = 10;
let mut handles = Vec::new();
for i in 0..max_iterations {
let join_set = workflow_support::join_set_create_bt(None);
let join_set = workflow_support::join_set_create();
step_submit(&join_set, i, i * 200);
handles.push((i, join_set));
}
log::info("parallel submitted all child executions");
let mut acc = 0;
for (i, join_set) in handles {
let (_execution_id, result) =
step_await_next(&join_set).expect("every join set has 1 execution");
let result = step_await_next(&join_set).expect("every join set has 1 execution");
let result = result.inspect_err(|_| log::error("step timed out"))?;
acc = 10 * acc + result; // order-sensitive
log::info(&format!("step({i})={result}, acc={acc}"));
workflow_support::sleep_bt(ScheduleAt::In(Duration::Milliseconds(300)), None)?;
workflow_support::sleep(ScheduleAt::In(Duration::Milliseconds(300)), None)?;
}
log::info(&format!("parallel completed: {acc}"));
Ok(acc)
Expand Down
Loading
Loading