Skip to content

Commit

Permalink
chore: fix wasi-keyvalue incoming value ownership mismatch
Browse files Browse the repository at this point in the history
WebAssembly/wasi-keyvalue#39

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
  • Loading branch information
rvolosatovs committed Feb 12, 2024
1 parent 9b96287 commit 828248e
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 43 deletions.
4 changes: 2 additions & 2 deletions crates/actor/wit/deps.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ sha512 = "49184a1b0945a889abd52d25271172ed3dc2db6968fcdddb1bab7ee0081f4a3eeee097

[keyvalue]
path = "../../runtime/wit/deps/keyvalue"
sha256 = "71b13c24d483e7f055aa8ebf87932abe931ff490764ec2a3f1fcc63c35bfb894"
sha512 = "c8ae7216f58923aa6bf9e3da9c17320bff2b5497d29dff0f70845efdfcff6b85cf6b8eb57b43b02f208a17531dfb5c972ae952d20f7f5fe68abdb71fb91f9ea4"
sha256 = "4ee1524f28b599c92ff9d6fae2a265d44e4e2ab41e9ac0dc3cbff1111008a4ce"
sha512 = "bf6a6628978e56e94307ef8a67546ed381343e07992419084400ee64d351c3eedaac6cf0d9889c96f22d32076b1c070d1547161787c218fcee4ff8ae08535a13"

[logging]
path = "../../runtime/wit/deps/logging"
Expand Down
6 changes: 3 additions & 3 deletions crates/actor/wit/deps/keyvalue/types.wit
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ interface types {
resource incoming-value {
/// Consumes the value synchronously and returns the value as a list of bytes.
/// If any other error occurs, it returns an `Err(error)`.
incoming-value-consume-sync: func() -> result<incoming-value-sync-body, error>;
incoming-value-consume-sync: static func(this: incoming-value) -> result<incoming-value-sync-body, error>;
/// Consumes the value asynchronously and returns the value as an `input-stream`.
/// If any other error occurs, it returns an `Err(error)`.
incoming-value-consume-async: func() -> result<incoming-value-async-body, error>;
incoming-value-consume-async: static func(this: incoming-value) -> result<incoming-value-async-body, error>;
/// The size of the value in bytes.
/// If the size is unknown or unavailable, this function returns an `Err(error)`.
incoming-value-size: func() -> result<u64, error>;
}
type incoming-value-async-body = input-stream;
type incoming-value-sync-body = list<u8>;
}
}
6 changes: 3 additions & 3 deletions crates/runtime/wit/deps.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ sha256 = "7210e5653539a15478f894d4da24cc69d61924cbcba21d2804d69314a88e5a4c"
sha512 = "49184a1b0945a889abd52d25271172ed3dc2db6968fcdddb1bab7ee0081f4a3eeee0977ad2291126a37631c0d86eeea75d822fa8af224c422134500bf9f0f2bb"

[keyvalue]
url = "https://github.com/WebAssembly/wasi-keyvalue/archive/main.tar.gz"
sha256 = "71b13c24d483e7f055aa8ebf87932abe931ff490764ec2a3f1fcc63c35bfb894"
sha512 = "c8ae7216f58923aa6bf9e3da9c17320bff2b5497d29dff0f70845efdfcff6b85cf6b8eb57b43b02f208a17531dfb5c972ae952d20f7f5fe68abdb71fb91f9ea4"
url = "https://github.com/WebAssembly/wasi-keyvalue/archive/cb1663e30553b36e82335552294572afcb122f27.tar.gz"
sha256 = "4ee1524f28b599c92ff9d6fae2a265d44e4e2ab41e9ac0dc3cbff1111008a4ce"
sha512 = "bf6a6628978e56e94307ef8a67546ed381343e07992419084400ee64d351c3eedaac6cf0d9889c96f22d32076b1c070d1547161787c218fcee4ff8ae08535a13"

[logging]
url = "https://github.com/WebAssembly/wasi-logging/archive/main.tar.gz"
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime/wit/deps.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
blobstore = "https://github.com/WebAssembly/wasi-blobstore/archive/main.tar.gz"
http = "https://github.com/WebAssembly/wasi-http/archive/v0.2.0.tar.gz"
io = "../../../wit/deps/io"
keyvalue = "https://github.com/WebAssembly/wasi-keyvalue/archive/main.tar.gz"
keyvalue = "https://github.com/WebAssembly/wasi-keyvalue/archive/cb1663e30553b36e82335552294572afcb122f27.tar.gz"
logging = "https://github.com/WebAssembly/wasi-logging/archive/main.tar.gz"
messaging = "https://github.com/wasmCloud/messaging/archive/main.tar.gz"
wasmcloud = "../../../wit"
6 changes: 3 additions & 3 deletions crates/runtime/wit/deps/keyvalue/types.wit
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ interface types {
resource incoming-value {
/// Consumes the value synchronously and returns the value as a list of bytes.
/// If any other error occurs, it returns an `Err(error)`.
incoming-value-consume-sync: func() -> result<incoming-value-sync-body, error>;
incoming-value-consume-sync: static func(this: incoming-value) -> result<incoming-value-sync-body, error>;
/// Consumes the value asynchronously and returns the value as an `input-stream`.
/// If any other error occurs, it returns an `Err(error)`.
incoming-value-consume-async: func() -> result<incoming-value-async-body, error>;
incoming-value-consume-async: static func(this: incoming-value) -> result<incoming-value-async-body, error>;
/// The size of the value in bytes.
/// If the size is unknown or unavailable, this function returns an `Err(error)`.
incoming-value-size: func() -> result<u64, error>;
}
type incoming-value-async-body = input-stream;
type incoming-value-sync-body = list<u8>;
}
}
6 changes: 3 additions & 3 deletions examples/golang/actors/http-hello-world/wit/deps.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ sha256 = "7210e5653539a15478f894d4da24cc69d61924cbcba21d2804d69314a88e5a4c"
sha512 = "49184a1b0945a889abd52d25271172ed3dc2db6968fcdddb1bab7ee0081f4a3eeee0977ad2291126a37631c0d86eeea75d822fa8af224c422134500bf9f0f2bb"

[keyvalue]
url = "https://github.com/WebAssembly/wasi-keyvalue/archive/main.tar.gz"
sha256 = "71b13c24d483e7f055aa8ebf87932abe931ff490764ec2a3f1fcc63c35bfb894"
sha512 = "c8ae7216f58923aa6bf9e3da9c17320bff2b5497d29dff0f70845efdfcff6b85cf6b8eb57b43b02f208a17531dfb5c972ae952d20f7f5fe68abdb71fb91f9ea4"
url = "https://github.com/WebAssembly/wasi-keyvalue/archive/cb1663e30553b36e82335552294572afcb122f27.tar.gz"
sha256 = "4ee1524f28b599c92ff9d6fae2a265d44e4e2ab41e9ac0dc3cbff1111008a4ce"
sha512 = "bf6a6628978e56e94307ef8a67546ed381343e07992419084400ee64d351c3eedaac6cf0d9889c96f22d32076b1c070d1547161787c218fcee4ff8ae08535a13"
deps = ["io"]

[logging]
Expand Down
2 changes: 1 addition & 1 deletion examples/golang/actors/http-hello-world/wit/deps.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
http = "https://github.com/WebAssembly/wasi-http/archive/v0.2.0.tar.gz"
keyvalue = "https://github.com/WebAssembly/wasi-keyvalue/archive/main.tar.gz"
keyvalue = "https://github.com/WebAssembly/wasi-keyvalue/archive/cb1663e30553b36e82335552294572afcb122f27.tar.gz"
logging = "https://github.com/WebAssembly/wasi-logging/archive/main.tar.gz"
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ interface types {
resource incoming-value {
/// Consumes the value synchronously and returns the value as a list of bytes.
/// If any other error occurs, it returns an `Err(error)`.
incoming-value-consume-sync: func() -> result<incoming-value-sync-body, error>;
incoming-value-consume-sync: static func(this: incoming-value) -> result<incoming-value-sync-body, error>;
/// Consumes the value asynchronously and returns the value as an `input-stream`.
/// If any other error occurs, it returns an `Err(error)`.
incoming-value-consume-async: func() -> result<incoming-value-async-body, error>;
incoming-value-consume-async: static func(this: incoming-value) -> result<incoming-value-async-body, error>;
/// The size of the value in bytes.
/// If the size is unknown or unavailable, this function returns an `Err(error)`.
incoming-value-size: func() -> result<u64, error>;
}
type incoming-value-async-body = input-stream;
type incoming-value-sync-body = list<u8>;
}
}
6 changes: 3 additions & 3 deletions examples/python/actors/http-hello-world/wit/deps.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ sha256 = "7210e5653539a15478f894d4da24cc69d61924cbcba21d2804d69314a88e5a4c"
sha512 = "49184a1b0945a889abd52d25271172ed3dc2db6968fcdddb1bab7ee0081f4a3eeee0977ad2291126a37631c0d86eeea75d822fa8af224c422134500bf9f0f2bb"

[keyvalue]
url = "https://github.com/WebAssembly/wasi-keyvalue/archive/main.tar.gz"
sha256 = "71b13c24d483e7f055aa8ebf87932abe931ff490764ec2a3f1fcc63c35bfb894"
sha512 = "c8ae7216f58923aa6bf9e3da9c17320bff2b5497d29dff0f70845efdfcff6b85cf6b8eb57b43b02f208a17531dfb5c972ae952d20f7f5fe68abdb71fb91f9ea4"
url = "https://github.com/WebAssembly/wasi-keyvalue/archive/cb1663e30553b36e82335552294572afcb122f27.tar.gz"
sha256 = "4ee1524f28b599c92ff9d6fae2a265d44e4e2ab41e9ac0dc3cbff1111008a4ce"
sha512 = "bf6a6628978e56e94307ef8a67546ed381343e07992419084400ee64d351c3eedaac6cf0d9889c96f22d32076b1c070d1547161787c218fcee4ff8ae08535a13"
deps = ["io"]

[logging]
Expand Down
2 changes: 1 addition & 1 deletion examples/python/actors/http-hello-world/wit/deps.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
http = "https://github.com/WebAssembly/wasi-http/archive/v0.2.0.tar.gz"
keyvalue = "https://github.com/WebAssembly/wasi-keyvalue/archive/main.tar.gz"
keyvalue = "https://github.com/WebAssembly/wasi-keyvalue/archive/cb1663e30553b36e82335552294572afcb122f27.tar.gz"
logging = "https://github.com/WebAssembly/wasi-logging/archive/main.tar.gz"
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ interface types {
resource incoming-value {
/// Consumes the value synchronously and returns the value as a list of bytes.
/// If any other error occurs, it returns an `Err(error)`.
incoming-value-consume-sync: func() -> result<incoming-value-sync-body, error>;
incoming-value-consume-sync: static func(this: incoming-value) -> result<incoming-value-sync-body, error>;
/// Consumes the value asynchronously and returns the value as an `input-stream`.
/// If any other error occurs, it returns an `Err(error)`.
incoming-value-consume-async: func() -> result<incoming-value-async-body, error>;
incoming-value-consume-async: static func(this: incoming-value) -> result<incoming-value-async-body, error>;
/// The size of the value in bytes.
/// If the size is unknown or unavailable, this function returns an `Err(error)`.
incoming-value-size: func() -> result<u64, error>;
}
type incoming-value-async-body = input-stream;
type incoming-value-sync-body = list<u8>;
}
}
6 changes: 3 additions & 3 deletions examples/rust/actors/http-hello-world/wit/deps.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ sha256 = "7210e5653539a15478f894d4da24cc69d61924cbcba21d2804d69314a88e5a4c"
sha512 = "49184a1b0945a889abd52d25271172ed3dc2db6968fcdddb1bab7ee0081f4a3eeee0977ad2291126a37631c0d86eeea75d822fa8af224c422134500bf9f0f2bb"

[keyvalue]
url = "https://github.com/WebAssembly/wasi-keyvalue/archive/main.tar.gz"
sha256 = "71b13c24d483e7f055aa8ebf87932abe931ff490764ec2a3f1fcc63c35bfb894"
sha512 = "c8ae7216f58923aa6bf9e3da9c17320bff2b5497d29dff0f70845efdfcff6b85cf6b8eb57b43b02f208a17531dfb5c972ae952d20f7f5fe68abdb71fb91f9ea4"
url = "https://github.com/WebAssembly/wasi-keyvalue/archive/cb1663e30553b36e82335552294572afcb122f27.tar.gz"
sha256 = "4ee1524f28b599c92ff9d6fae2a265d44e4e2ab41e9ac0dc3cbff1111008a4ce"
sha512 = "bf6a6628978e56e94307ef8a67546ed381343e07992419084400ee64d351c3eedaac6cf0d9889c96f22d32076b1c070d1547161787c218fcee4ff8ae08535a13"
deps = ["io"]

[logging]
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/actors/http-hello-world/wit/deps.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
http = "https://github.com/WebAssembly/wasi-http/archive/v0.2.0.tar.gz"
keyvalue = "https://github.com/WebAssembly/wasi-keyvalue/archive/main.tar.gz"
keyvalue = "https://github.com/WebAssembly/wasi-keyvalue/archive/cb1663e30553b36e82335552294572afcb122f27.tar.gz"
logging = "https://github.com/WebAssembly/wasi-logging/archive/main.tar.gz"
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ interface types {
resource incoming-value {
/// Consumes the value synchronously and returns the value as a list of bytes.
/// If any other error occurs, it returns an `Err(error)`.
incoming-value-consume-sync: func() -> result<incoming-value-sync-body, error>;
incoming-value-consume-sync: static func(this: incoming-value) -> result<incoming-value-sync-body, error>;
/// Consumes the value asynchronously and returns the value as an `input-stream`.
/// If any other error occurs, it returns an `Err(error)`.
incoming-value-consume-async: func() -> result<incoming-value-async-body, error>;
incoming-value-consume-async: static func(this: incoming-value) -> result<incoming-value-async-body, error>;
/// The size of the value in bytes.
/// If the size is unknown or unavailable, this function returns an `Err(error)`.
incoming-value-size: func() -> result<u64, error>;
}
type incoming-value-async-body = input-stream;
type incoming-value-sync-body = list<u8>;
}
}
19 changes: 9 additions & 10 deletions tests/actors/rust/builtins-component-reactor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,7 @@ impl exports::wasi::http::incoming_handler::Guest for Actor {
.expect("failed to get `foo` size");
assert_eq!(foo_value_size, 3);

let foo_value = foo_value
.incoming_value_consume_sync()
let foo_value = keyvalue::types::IncomingValue::incoming_value_consume_sync(foo_value)
.map_err(|e| e.trace())
.expect("failed to get incoming value buffer");
assert_eq!(foo_value, b"bar");
Expand All @@ -238,10 +237,10 @@ impl exports::wasi::http::incoming_handler::Guest for Actor {
.map_err(|e| e.trace())
.expect("failed to get `foo`")
.expect("`foo` does not exist in bucket");
let mut foo_stream = foo_value
.incoming_value_consume_async()
.map_err(|e| e.trace())
.expect("failed to get incoming value stream");
let mut foo_stream =
keyvalue::types::IncomingValue::incoming_value_consume_async(foo_value)
.map_err(|e| e.trace())
.expect("failed to get incoming value stream");
let mut foo_value = vec![];
let n = InputStreamReader::from(&mut foo_stream)
.read_to_end(&mut foo_value)
Expand Down Expand Up @@ -275,10 +274,10 @@ impl exports::wasi::http::incoming_handler::Guest for Actor {
.map_err(|e| e.trace())
.expect("failed to get `result`")
.expect("`result` does not exist in bucket");
let result_value = result_value
.incoming_value_consume_sync()
.map_err(|e| e.trace())
.expect("failed to get incoming value buffer");
let result_value =
keyvalue::types::IncomingValue::incoming_value_consume_sync(result_value)
.map_err(|e| e.trace())
.expect("failed to get incoming value buffer");
assert_eq!(result_value, body);

let result_value = keyvalue::types::OutgoingValue::new_outgoing_value();
Expand Down

0 comments on commit 828248e

Please sign in to comment.