-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Document workers/deno/bun * Fix broken links * fix serving_fetch.ts * Cf -> deno
- Loading branch information
1 parent
53bd5df
commit ae7e185
Showing
15 changed files
with
176 additions
and
14 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 @@ | ||
const myService = restate.service({ | ||
name: "MyService", | ||
handlers: {}, | ||
}); | ||
|
||
const myVirtualObject = restate.object({ | ||
name: "MyVirtualObject", | ||
handlers: {}, | ||
}); | ||
|
||
const myWorkflow = restate.workflow({ | ||
name: "MyWorkflow", | ||
handlers: { run: async () => {} }, | ||
}); | ||
|
||
// <start_fetch> | ||
import * as restate from "@restatedev/restate-sdk/fetch"; | ||
const handler = restate | ||
.endpoint() | ||
.bind(myService) | ||
.bind(myVirtualObject) | ||
.bind(myWorkflow) | ||
.handler(); | ||
// Cloudflare expects the handler as a default export | ||
export default handler; | ||
// Bun expects an object containing the inner fetch function | ||
Bun.serve({ | ||
port: 9080, | ||
...handler, | ||
}); | ||
// Deno expects to be passed the fetch function | ||
Deno.serve({ port: 9080 }, handler.fetch); | ||
// <end_fetch> | ||
|
||
namespace Bun { | ||
export function serve(_: object): void {} | ||
} | ||
namespace Deno { | ||
export function serve(a: object, b: object): void {} | ||
} |
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 @@ | ||
{ | ||
"label": "FaaS", | ||
"position": 3, | ||
"link": { | ||
"type": "generated-index", | ||
"title": "FaaS" | ||
} | ||
} |
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,32 @@ | ||
--- | ||
label: "deno-deploy" | ||
sidebar_position: 3 | ||
description: "Learn how to run Restate TypeScript services on Deno Deploy." | ||
--- | ||
|
||
# Deno Deploy | ||
|
||
You can run your Restate services as serverless functions on [Deno Deploy](https://deno.com/deploy). | ||
|
||
You can easily get started using the | ||
[Deno+Restate template](https://github.com/restatedev/examples/tree/main/templates/deno): | ||
```shell CLI | ||
# link(1:3) /develop/local_dev#running-restate-server--cli-locally | ||
restate example typescript-deno-hello-world && | ||
cd typescript-deno-hello-world | ||
``` | ||
|
||
You can also add Restate into an existing Deno project. The SDK should be imported with the `fetch` component eg | ||
`npm:@restatedev/restate-sdk@^VAR::TYPESCRIPT_SDK_VERSION/fetch` and you would serve with `Deno.serve({ port: 9080 }, handler.fetch)`. | ||
|
||
You can deploy to Deno Run with `deployctl deploy`, and register your deployed | ||
service: | ||
```shell CLI | ||
restate deployments register https://my-service.deno.dev | ||
``` | ||
|
||
Local development is as simple as running your `main.ts` and discovering the local | ||
port: | ||
```shell CLI | ||
restate deployments register http://localhost:9080 | ||
``` |
2 changes: 1 addition & 1 deletion
2
docs/deploy/lambda/_category_.json → docs/deploy/faas/lambda/_category_.json
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
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,37 @@ | ||
--- | ||
label: "cloudflare-workers" | ||
sidebar_position: 2 | ||
description: "Learn how to run Restate TypeScript services on Cloudflare Workers." | ||
--- | ||
|
||
# Cloudflare Workers | ||
|
||
You can run your Restate services as serverless functions on [Cloudflare Workers](https://workers.cloudflare.com/). | ||
|
||
You can easily get started using the | ||
[Workers+Restate template](https://github.com/restatedev/examples/tree/main/templates/cloudflare-worker): | ||
```shell CLI | ||
# link(1:3) /develop/local_dev#running-restate-server--cli-locally | ||
restate example typescript-cloudflare-worker-hello-world && | ||
cd typescript-cloudflare-worker-hello-world | ||
``` | ||
|
||
You can also add Restate into the standard `wrangler init` template, as long | ||
as you have the `nodejs_compat` compatibility flag set in `wrangler.toml`. | ||
The SDK should be imported with the `fetch` component | ||
`@restatedev/restate-sdk/fetch` and you would expose your endpoint to the Worker | ||
runtime with `export default endpoint().bind(...).handler()`. | ||
|
||
You can deploy with `wrangler deploy`, and register your deployed | ||
service: | ||
```shell CLI | ||
restate deployments register https://my-service.my-domain.workers.dev | ||
``` | ||
|
||
## Local development | ||
|
||
A Workers dev server can be started on port 9080 using | ||
`wrangler dev --port 9080`. `wrangler dev` only serves over HTTP1.1, so you'll need to register a local service with: | ||
```shell CLI | ||
restate deployments register --use-http1.1 http://localhost:9080 | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/deploy/lambda/* /deploy/faas/lambda/:splat 301 |