-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add actor runtime docs (#1559)
<!-- Please make sure there is an issue that this PR is correlated to. --> Fixes RVT-4316 ## Changes <!-- If there are frontend changes, please include screenshots. -->
- Loading branch information
1 parent
a3c99f8
commit 3af0f5f
Showing
3 changed files
with
322 additions
and
262 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,58 @@ | ||
# Actor Runtime | ||
|
||
The actor runtime requires that user scripts contain a default export with a function called `start`: | ||
|
||
```ts {{"file": "index.js"}} | ||
export default { | ||
start: function(ctx: ActorContext) { | ||
// ... | ||
} | ||
}; | ||
``` | ||
|
||
This can also be a class with a static method: | ||
|
||
```ts {{"file": "index.js"}} | ||
export default class MyClass { | ||
static start(ctx: ActorContext) { | ||
// ... | ||
} | ||
} | ||
``` | ||
|
||
The runtime provides a single argument with type `ActorContext`: | ||
|
||
```ts | ||
interface ActorContext { | ||
metadata: { | ||
actor: { | ||
id: string; | ||
tags: Record<string, string>; | ||
createdAt: Date; | ||
}; | ||
project: { | ||
id: string; | ||
slug: string; | ||
}; | ||
environment: { | ||
id: string; | ||
slug: string; | ||
}; | ||
cluster: { | ||
id: string; | ||
}; | ||
region: { | ||
id: string; | ||
name: string; | ||
}; | ||
build: { | ||
id: string; | ||
}; | ||
}; | ||
kv: { | ||
// ...See docs for state... † | ||
}; | ||
} | ||
``` | ||
|
||
_[† state](/docs/state#operations)_ |
Oops, something went wrong.