Skip to content

Commit f35b5d5

Browse files
committed
docs: clean up separation between actors/containers/functions (#2394)
<!-- Please make sure there is an issue that this PR is correlated to. --> ## Changes <!-- If there are frontend changes, please include screenshots. -->
1 parent 37f42ce commit f35b5d5

File tree

17 files changed

+426
-126
lines changed

17 files changed

+426
-126
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ iwr https://releases.rivet.gg/rivet/latest/install.ps1 -useb | iex
7272

7373
### Quickstart (TypeScript)
7474

75-
_See the [full quickstart guide](https://rivet.gg/docs/quickstart/typescript) for a comprehensive walkthrough._
75+
_See the [full quickstart guide](https://rivet.gg/docs/actors) for a comprehensive walkthrough._
7676

7777
**Step 1: Create Actor**
7878

frontend/packages/components/src/actors/get-started.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Icon, faTs } from "@rivet-gg/icons";
1+
import { Icon, faTs, faFunction, faServer, faActors } from "@rivet-gg/icons";
22
import { motion } from "framer-motion";
33
import type { ComponentProps } from "react";
44
import { Button } from "../ui/button";
@@ -15,8 +15,20 @@ export function ActorsResources() {
1515
</CardHeader>
1616
<CardContent className="grid md:grid-cols-2 gap-4">
1717
<ExampleLink
18-
href="docs/quickstart/typescript"
19-
title="TypeScript"
18+
href="docs/actors"
19+
title="Rivet Actors"
20+
size="md"
21+
icon={faActors}
22+
/>
23+
<ExampleLink
24+
href="docs/containers"
25+
title="Rivet Containers"
26+
size="md"
27+
icon={faServer}
28+
/>
29+
<ExampleLink
30+
href="docs/functions"
31+
title="Rivet Functions"
2032
size="md"
2133
icon={faTs}
2234
/>

site/_redirects

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
/docs/html5/* https://opengamebackend.org/game-engines/html5 302
55
/docs/custom/* https://opengamebackend.org/game-engines/html5 302
66
/modules/* https://opengamebackend.org/modules 302
7+
/docs/javascript-runtime /docs/actors 302
8+
/docs/container-runtime /docs/containers 302

site/scripts/generateApi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export async function main() {
2727
for (let method in SPEC.paths[pathName]) {
2828
let specPath = SPEC.paths[pathName][method];
2929

30-
if (!/^(actors|builds|regions)_/.test(specPath.operationId)) continue;
30+
if (!/^(actors|builds|regions|routes)_/.test(specPath.operationId)) continue;
3131

3232
console.log('Registering', method, pathName);
3333

site/src/content/docs/javascript-runtime.mdx renamed to site/src/content/docs/actors.mdx

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
# JavaScript Runtime
1+
# Rivet Actors
22

3-
The Rivet JavaScript runtime is built on lightweight JavaScript containers called V8 isolates, providing a high-performance, secure environment for your actor code.
4-
5-
It's designed to be widely compatible with Node.js and NPM dependencies, making it easy to use familiar libraries and tools.
3+
Rivet Actors allows you to deploy resilient, stateful services that maintain their state between requests. Use them for websocket servers, game backends, real-time collaboration services, and more.
64

75
<Tip title="Get Started Faster With ActorCore">
86
For getting started quickly using JavaScript, we recommend trying [ActorCore](https://actorcore.org) – our full-stack framework for working with Rivet Actors.
97
</Tip>
108

11-
## Basic Setup
9+
## What are actors good for?
10+
11+
- **Stateful Services**: Applications where maintaining state across interactions is critical. For example, **Collaborative Apps** with shared editing and automatic persistence.
12+
- **Realtime Systems**: Applications requiring fast, in-memory state modifications or push updates to connected clients. For example, **Multiplayer Games** with game rooms and player state.
13+
- **Long-Running Processes**: Tasks that execute over extended periods or in multiple steps. For example, **AI Agents** with ongoing conversations and stateful tool calls.
14+
- **Durability**: Processes that must survive crashes and restarts without data loss. For example, **Durable Execution** workflows that continue after system restarts.
15+
- **Horizontal Scalability**: Systems that need to scale by distributing load across many instances. For example, **Realtime Stream Processing** for stateful event handling.
16+
- **Local-First Architecture**: Systems that synchronize state between offline clients. For example, **Local-First Sync** between devices.
17+
18+
## Quickstart
1219

1320
### Step 1: Writing an actor
1421

@@ -26,22 +33,20 @@ Every actor must export a default object with an async `start` function. Here's
2633

2734
```ts {{"file": "src/index.ts"}}
2835
import type { ActorContext } from "@rivet-gg/actor";
29-
import * as http from "http";
36+
import { Hono } from "hono";
3037

3138
export default {
3239
async start(ctx: ActorContext) {
33-
// Get the port from environment variables or use a default
34-
const port = parseInt(process.env.PORT_HTTP || "8080");
40+
const port = parseInt(Deno.env.get("PORT_HTTP") || "8080");
3541
console.log(`HTTP server running on port ${port}`);
3642

37-
// Create an HTTP server
38-
const server = http.createServer((req, res) => {
39-
res.writeHead(200, { "Content-Type": "text/plain" });
40-
res.end(`Hello from Rivet Actor ${ctx.metadata.actor.id} running in ${ctx.metadata.region.id}!`);
43+
const app = new Hono();
44+
45+
app.get("/", (c) => {
46+
return c.text(`Hello from Rivet Actor ${ctx.metadata.actor.id} running in ${ctx.metadata.region.id}!`);
4147
});
4248

43-
// Start listening on the specified port
44-
server.listen(port);
49+
Deno.serve({ port }, app.fetch);
4550

4651
// Keep the actor running until explicitly destroyed
4752
await new Promise((resolve) => {});
@@ -50,8 +55,8 @@ export default {
5055
```
5156

5257
What this code does:
53-
- Sets up a simple HTTP server using Node.js's built-in http module
54-
- Creates a response that includes the actor ID and region information
58+
- Creates a simple HTTP server using Hono with Deno
59+
- Sets up a route that returns the actor ID and region information
5560
- Keeps the actor running indefinitely by returning a promise that never resolves
5661

5762
<Tip title="Using classes">
@@ -74,7 +79,7 @@ Specify the script in your `rivet.json`:
7479

7580
```json {{ "title": "rivet.json" }}
7681
{
77-
"builds": {
82+
"actors": {
7883
"my-actor": {
7984
"script": "./src/index.ts"
8085
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{/* This file is auto-generated by `generateApi.js`.
2+
*
3+
* Do not edit this file directly.
4+
*/}
5+
6+
import { JsonSchemaPreview, PropertyLabel } from '@/components/JsonSchemaPreview';
7+
import API_SCHEMA from './../spec.json';
8+
9+
# routes.delete
10+
11+
## Description
12+
Deletes a route.
13+
14+
## Code Examples
15+
16+
<CodeGroup title='Request' tag='DELETE' label='https://api.rivet.gg/routes/{id}'>
17+
18+
```bash {{ "title": "cURL" }}
19+
curl -X DELETE 'https://api.rivet.gg/routes/{id}'
20+
```
21+
22+
```ts
23+
// Create Rivet client
24+
import { RivetClient } from '@rivet-gg/api';
25+
const RIVET = new RivetClient({ token: '[YOUR TOKEN HERE]' });
26+
27+
// Make request
28+
await RIVET.routes.delete({
29+
// Add your request body here
30+
});
31+
```
32+
33+
</CodeGroup>
34+
35+
## Schema
36+
<JsonSchemaPreview className='not-prose mt-4' title='Request Parameters' schema={{"type":"object","properties":{"id":{"in":"path","type":"string"},"project":{"in":"query","type":"string"},"environment":{"in":"query","type":"string"}},"required":["id"]}} defs={API_SCHEMA.definitions}/>
37+
<JsonSchemaPreview className='not-prose mt-4' title='Response' schema={{"$ref":"#/components/schemas/RoutesDeleteRouteResponse"}} defs={API_SCHEMA.definitions}/>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{/* This file is auto-generated by `generateApi.js`.
2+
*
3+
* Do not edit this file directly.
4+
*/}
5+
6+
import { JsonSchemaPreview, PropertyLabel } from '@/components/JsonSchemaPreview';
7+
import API_SCHEMA from './../spec.json';
8+
9+
# routes.list
10+
11+
## Description
12+
Lists all routes of the given environment.
13+
14+
## Code Examples
15+
16+
<CodeGroup title='Request' tag='GET' label='https://api.rivet.gg/routes'>
17+
18+
```bash {{ "title": "cURL" }}
19+
curl -X GET 'https://api.rivet.gg/routes'
20+
```
21+
22+
```ts
23+
// Create Rivet client
24+
import { RivetClient } from '@rivet-gg/api';
25+
const RIVET = new RivetClient({ token: '[YOUR TOKEN HERE]' });
26+
27+
// Make request
28+
await RIVET.routes.list({
29+
// Add your request body here
30+
});
31+
```
32+
33+
</CodeGroup>
34+
35+
## Schema
36+
<JsonSchemaPreview className='not-prose mt-4' title='Request Parameters' schema={{"type":"object","properties":{"project":{"in":"query","type":"string"},"environment":{"in":"query","type":"string"}},"required":[]}} defs={API_SCHEMA.definitions}/>
37+
<JsonSchemaPreview className='not-prose mt-4' title='Response' schema={{"$ref":"#/components/schemas/RoutesListRoutesResponse"}} defs={API_SCHEMA.definitions}/>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{/* This file is auto-generated by `generateApi.js`.
2+
*
3+
* Do not edit this file directly.
4+
*/}
5+
6+
import { JsonSchemaPreview, PropertyLabel } from '@/components/JsonSchemaPreview';
7+
import API_SCHEMA from './../spec.json';
8+
9+
# routes.update
10+
11+
## Description
12+
Creates or updates a route.
13+
14+
## Code Examples
15+
16+
<CodeGroup title='Request' tag='PUT' label='https://api.rivet.gg/routes/{id}'>
17+
18+
```bash {{ "title": "cURL" }}
19+
# Write the request body to body.json before running
20+
curl -X PUT -d '@body.json' 'https://api.rivet.gg/routes/{id}'
21+
22+
23+
```
24+
25+
```ts
26+
// Create Rivet client
27+
import { RivetClient } from '@rivet-gg/api';
28+
const RIVET = new RivetClient({ token: '[YOUR TOKEN HERE]' });
29+
30+
// Make request
31+
await RIVET.routes.update({
32+
// Add your request body here
33+
});
34+
```
35+
36+
</CodeGroup>
37+
38+
## Schema
39+
<JsonSchemaPreview className='not-prose mt-4' title='Request Parameters' schema={{"type":"object","properties":{"id":{"in":"path","type":"string"},"project":{"in":"query","type":"string"},"environment":{"in":"query","type":"string"}},"required":["id"]}} defs={API_SCHEMA.definitions}/>
40+
<JsonSchemaPreview className='not-prose mt-4' title='Request' schema={{"$ref":"#/components/schemas/RoutesUpdateRouteBody"}} defs={API_SCHEMA.definitions}/>
41+
<JsonSchemaPreview className='not-prose mt-4' title='Response' schema={{"$ref":"#/components/schemas/RoutesUpdateRouteResponse"}} defs={API_SCHEMA.definitions}/>

0 commit comments

Comments
 (0)