Skip to content

Commit 845bf20

Browse files
authored
Merge pull request #35 from golemcloud/fork
Exposed the new fork function
2 parents fe5b1de + 9b67579 commit 845bf20

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

golem-rust/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ use bindings::golem::api::host::*;
187187

188188
pub use golem_wasm_rpc as wasm_rpc;
189189

190-
pub use bindings::golem::api::host::oplog_commit;
191-
pub use bindings::golem::api::host::PersistenceLevel;
190+
pub use bindings::golem::api::host::{fork, oplog_commit};
191+
pub use bindings::golem::api::host::{ForkResult, PersistenceLevel};
192192

193193
pub use transaction::*;
194194

golem-rust/wit/deps.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[all]
2-
url = "https://github.com/golemcloud/golem-wit/archive/v1.2.2-dev.9.tar.gz"
2+
url = "https://github.com/golemcloud/golem-wit/archive/fork.tar.gz"
33
sha256 = "6ac4f1553003474229bb40a885b48d1eaa4bea2f9d679a115da9afede30b5ad4"
44
sha512 = "ced8c18a35dc04123386465d98d2aeba54c486e4e22a30e7efac0548974e176528fcba36c64942d67fa35d9135806ff0fcde259eb4af051c4a29fcb397e9af1c"
55
deps = ["blobstore", "cli", "clocks", "filesystem", "golem-1.x", "golem-durability", "golem-rpc", "http", "io", "keyvalue", "logging", "random", "sockets"]
@@ -21,8 +21,8 @@ sha256 = "498c465cfd04587db40f970fff2185daa597d074c20b68a8bcbae558f261499b"
2121
sha512 = "ead452f9b7bfb88593a502ec00d76d4228003d51c40fd0408aebc32d35c94673551b00230d730873361567cc209ec218c41fb4e95bad194268592c49e7964347"
2222

2323
["golem-1.x"]
24-
sha256 = "98562a7e1e3eb630a9cbfa18fee73a3d1766854e99c48e30f815f71128f4063f"
25-
sha512 = "1c75cd7b1b856923d1edd5ed15c4be0d5a27c5117d9c3e8de797ca9d2bc7dc0e919372b89560a2ae1fd9c15325afd2c9bb3f3eb0ecbc78086ccfab5e756762ed"
24+
sha256 = "6de94b37f084824d52b7f160b9a410141d450c901df4f4bd742401693d01459f"
25+
sha512 = "50466e796788a8bd09f6699e0a27ac37f7ba074e3962a70c5f8e9241e2930e4ecab0b16e0e8b165c2a72528d7f287efe0ace74790f8e9c098fcf7b12018dbd46"
2626

2727
[golem-durability]
2828
sha256 = "8c6091df29f803d87b22656101cf263f2a2e677d9585075f22b168c7a3e4c383"

golem-rust/wit/deps.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
all = "https://github.com/golemcloud/golem-wit/archive/v1.2.2-dev.9.tar.gz"
1+
all = "https://github.com/golemcloud/golem-wit/archive/fork.tar.gz"
22
rdbms = "https://github.com/golemcloud/golem-rdbms/archive/main.tar.gz"

golem-rust/wit/deps/golem-1.x/golem-host.wit

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ interface host {
155155
revert-last-invocations(u64)
156156
}
157157

158+
/// Indicates which worker the code is running on after `fork`
159+
enum fork-result {
160+
/// The original worker that called `fork`
161+
original,
162+
/// The new worker
163+
forked
164+
}
165+
158166
/// Create a new promise
159167
create-promise: func() -> promise-id;
160168

@@ -256,6 +264,11 @@ interface host {
256264
/// Get the worker-id for a given component and worker name.
257265
/// Returns none when no component for the specified component-reference or no worker with the specified worker-name exists.
258266
resolve-worker-id-strict: func(component-reference: string, worker-name: string) -> option<worker-id>;
267+
268+
/// Forks the current worker at the current execution point. The new worker gets the `new-name` worker name,
269+
/// and this worker continues running as well. The return value is going to be different in this worker and
270+
/// the forked worker.
271+
fork: func(new-name: string) -> fork-result;
259272
}
260273

261274
/// Interface providing user-defined snapshotting capability. This can be used to perform manual update of workers

0 commit comments

Comments
 (0)