|
| 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