Skip to content

Commit 9d3ddc0

Browse files
committed
add @spinframework/spin-trigger-redis package
Signed-off-by: karthik2804 <[email protected]>
1 parent 36be83f commit 9d3ddc0

File tree

6 files changed

+106
-0
lines changed

6 files changed

+106
-0
lines changed

package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "@spinframework/spin-trigger-redis",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "dist/index.js",
6+
"types": "dist/index.d.ts",
7+
"type": "module",
8+
"scripts": {
9+
"build": "tsc"
10+
},
11+
"keywords": [],
12+
"author": "",
13+
"license": "Apache-2.0",
14+
"devDependencies": {
15+
"typescript": "^5.7.3"
16+
},
17+
"config": {
18+
"wasiDep": {
19+
"witDeps": [
20+
{
21+
"witPath": "./wit",
22+
"package": "fermyon:spin",
23+
"world": "spin-trigger-redis"
24+
}
25+
]
26+
}
27+
}
28+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Abstract class for handling Redis messages.
3+
*/
4+
export abstract class RedisHandler {
5+
/**
6+
* Handles a Redis message.
7+
* @param msg - The message data as a Uint8Array.
8+
* @returns A Promise that resolves when the message has been handled.
9+
*/
10+
abstract handleMessage(msg: Uint8Array): Promise<void>;
11+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"module": "ES2020",
5+
"lib": [
6+
"ES2020",
7+
"WebWorker"
8+
],
9+
"moduleResolution": "node",
10+
"declaration": true,
11+
"outDir": "dist",
12+
"strict": true,
13+
"esModuleInterop": true,
14+
},
15+
"exclude": [
16+
"node_modules",
17+
"dist"
18+
]
19+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
interface redis-types {
2+
// General purpose error.
3+
enum error {
4+
success,
5+
error,
6+
}
7+
8+
/// The message payload.
9+
type payload = list<u8>;
10+
11+
/// A parameter type for the general-purpose `execute` function.
12+
variant redis-parameter {
13+
int64(s64),
14+
binary(payload)
15+
}
16+
17+
/// A return type for the general-purpose `execute` function.
18+
variant redis-result {
19+
nil,
20+
status(string),
21+
int64(s64),
22+
binary(payload)
23+
}
24+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package fermyon:spin;
2+
3+
interface inbound-redis {
4+
use redis-types.{payload, error};
5+
6+
// The entrypoint for a Redis handler.
7+
handle-message: func(message: payload) -> result<_, error>;
8+
}
9+
10+
world spin-trigger-redis {
11+
export inbound-redis;
12+
}

0 commit comments

Comments
 (0)