Skip to content

Commit 1c5cb2f

Browse files
committed
add types for redis-execute
Signed-off-by: karthik Ganeshram <[email protected]>
1 parent 798ddff commit 1c5cb2f

File tree

6 files changed

+4
-28
lines changed

6 files changed

+4
-28
lines changed

Cargo.lock

Lines changed: 0 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/spin-js-engine/src/js_sdk/modules/spinSdk.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ interface SpinSDK {
4444
send: (arg0: BaseHttpRequest) => HttpResponse
4545
}
4646
redis: {
47+
execute: (address: string, args: Array< ArrayBuffer | bigint>) => undefined | string | bigint | ArrayBuffer
4748
get: (address: string, key: string) => ArrayBuffer
4849
incr: (address: string, key: string) => bigint
4950
publish: (address: string, channel: string, value: ArrayBuffer) => undefined

crates/spin-js-engine/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@ use {
1414
spin_sdk::{
1515
config,
1616
http::{Request, Response},
17-
<<<<<<< HEAD
1817
http_component,
1918
key_value::Store,
2019
outbound_http, redis,
21-
=======
22-
http_component, outbound_http, redis,
2320
redis::RedisResult,
24-
>>>>>>> 0081caf (initial commit)
2521
},
2622
std::{
2723
collections::HashMap,
@@ -342,7 +338,6 @@ fn redis_exec(context: &Context, _this: &Value, args: &[Value]) -> Result<Value>
342338
Binary(ByteBuf),
343339
}
344340

345-
println!("execcuting exec");
346341
match args {
347342
[address, command, arguments] => {
348343
let address = &deserialize_helper(address)?;
@@ -398,7 +393,7 @@ fn redis_exec(context: &Context, _this: &Value, args: &[Value]) -> Result<Value>
398393
return Ok(arr);
399394
}
400395
_ => bail!(
401-
"expected a two arguments (address, key), got {} arguments",
396+
"expected a three arguments (address, command, arguments), got {} arguments",
402397
args.len()
403398
),
404399
}

examples/typescript/outbound_redis/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"build": "npx webpack --mode=production && mkdir -p target && ../../../target/release/spinjs -o target/spin-http-js.wasm dist/spin.js",
7+
"build": "npx webpack --mode=production && mkdir -p target && spin js2wasm -o target/spin-http-js.wasm dist/spin.js",
88
"test": "echo \"Error: no test specified\" && exit 1"
99
},
1010
"keywords": [],

examples/typescript/outbound_redis/src/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ export const handleRequest: HandleRequest = async function (request: HttpRequest
1818

1919
spinSdk.redis.publish(redisAddress, "test", encoder.encode("This is a test").buffer)
2020

21-
//@ts-ignore
22-
spinSdk.redis.execute(redisAddress, "sadd", [BigInt(64), BigInt(617124)])
23-
2421
return {
2522
status: 200,
2623
headers: {"foo": "bar"},

types/lib/modules/spinSdk.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ interface KvStore {
2727
interface SpinSDK {
2828
config: SpinConfig;
2929
redis: {
30+
execute: (address: string, args: Array<ArrayBuffer | bigint>) => undefined | string | bigint | ArrayBuffer;
3031
get: (address: string, key: string) => ArrayBuffer;
3132
incr: (address: string, key: string) => bigint;
3233
publish: (address: string, channel: string, value: ArrayBuffer) => undefined;

0 commit comments

Comments
 (0)