-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document workers/deno/bun #436
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gvdongen fyi this is how you can set up a redirect on CF pages