This repository has been archived by the owner on Dec 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add support for tar images for js (#582)
Fixes RVT-4170
- Loading branch information
1 parent
f5c588b
commit 5930aa1
Showing
20 changed files
with
262 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Actor Crash Course | ||
|
||
## Prerequisites | ||
|
||
- Must have Rivet docker compose running | ||
- Must have hub running just for the device link | ||
|
||
## Actor test | ||
|
||
```bash | ||
cargo build | ||
cd examples/js-deno | ||
../../target/debug/rivet login --api-endpoint http://localhost:8080 | ||
# copy the path to localhost:5080/device/link/... and finish linking | ||
../../target/debug/rivet deploy default | ||
# copy build id | ||
../../target/debug/rivet actor create default -t name=rng --build MY_BUILD_ID --region local --network-mode host --port protocol=tcp,name=http,host | ||
# copy public_hostname and public_port | ||
curl 127.0.0.1:20081 | ||
../../target/debug/rivet actor destroy default --id MY_ACTOR_ID | ||
``` | ||
|
||
## Reference | ||
|
||
- See `rivet --help` for more commands | ||
- rivet.jsonc config spec at `packages/toolchain/src/config/mod.rs` | ||
- WIP typedefs for actors [here](https://github.com/rivet-gg/rivet/blob/925b9b5c2f024f40615e910e9670655249eb2bc7/sdks/actor-types/src/internal/90_rivet_ns.ts) | ||
|
||
## Known issues | ||
|
||
- Only supports host networking | ||
- Networking is not working (afaik) | ||
- LZ4 compression for JS tars don't work (defaults to correct compression, no action needed) | ||
|
||
## Troubleshooting | ||
|
||
### `Error getting bootstrap: get project failed` | ||
|
||
Make sure to run `rivet logout` if you reset the core cluster. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Without Rivet actor class | ||
|
||
const portStr = Deno.env.get("PORT_http") ?? Deno.env.get("HTTP_PORT"); | ||
if (!portStr) throw "Missing port"; | ||
const port = parseInt(portStr); | ||
if (!isFinite(port)) throw "Invalid port"; | ||
|
||
const server = Deno.serve({ | ||
handler, | ||
port, | ||
hostname: "0.0.0.0", | ||
}); | ||
|
||
await server.finished; | ||
|
||
async function handler(req: Request) { | ||
console.log("Received request"); | ||
|
||
let newCount = (await Rivet.kv.get("count") ?? 0) + 1; | ||
await Rivet.kv.put("count", newCount); | ||
|
||
return new Response(newCount.toString()); | ||
} | ||
|
||
// With Rivet actor class | ||
|
||
import { Actor } from "@rivet-gg/rivet"; | ||
|
||
interface State { | ||
count: number; | ||
} | ||
|
||
class Counter extends Actor<State> { | ||
initialize(): State { | ||
return { count: 0 }; | ||
} | ||
|
||
async onRequest(req) { | ||
this.count += 1; | ||
return new Response(this.count.toString()); | ||
} | ||
} | ||
|
||
Rivet.run(Counter); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
await Rivet.kv.put("count", 0); | ||
|
||
console.log('Started', Deno.env.toObject()); | ||
setInterval(async () => { | ||
let x = await Rivet.kv.get("count"); | ||
await Rivet.kv.put("count", x + 1); | ||
console.log('Count', x); | ||
}, 1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"version": "2.0", | ||
"builds": [ | ||
{ | ||
"tags": { "name": "kv" }, | ||
"runtime": "javascript", | ||
"bundler": "none", | ||
"script": "index.js" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.