Skip to content

Commit

Permalink
feat: add actor runtime docs (#1559)
Browse files Browse the repository at this point in the history
<!-- 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
MasterPtato committed Dec 10, 2024
1 parent a3c99f8 commit 3af0f5f
Show file tree
Hide file tree
Showing 3 changed files with 322 additions and 262 deletions.
58 changes: 58 additions & 0 deletions docs/src/content/docs/internals/runtime.mdx
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)_
Loading

0 comments on commit 3af0f5f

Please sign in to comment.