Skip to content

Commit

Permalink
Use new lambda handler API in docs (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkleeman authored Jul 2, 2024
1 parent 721e587 commit 8404d18
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 25 deletions.
14 changes: 7 additions & 7 deletions code_snippets/ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 1 addition & 11 deletions code_snippets/ts/src/develop/serving.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as restate from "@restatedev/restate-sdk";
import * as http2 from "http2";

const myService = restate.service({
Expand All @@ -17,6 +16,7 @@ const myWorkflow = restate.workflow({
});

// <start_endpoint>
import * as restate from "@restatedev/restate-sdk";
restate
.endpoint()
.bind(myService)
Expand All @@ -37,13 +37,3 @@ const http2Handler = restate
const httpServer = http2.createServer(http2Handler);
httpServer.listen();
// <end_custom_endpoint>

// <start_lambda>
export const handler = restate
.endpoint()
.bind(myService)
.bind(myVirtualObject)
.bind(myWorkflow)
// withClass highlight-line
.lambdaHandler();
// <end_lambda>
25 changes: 25 additions & 0 deletions code_snippets/ts/src/develop/serving_lambda.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const myService = restate.service({
name: "MyService",
handlers: {},
});

const myVirtualObject = restate.object({
name: "MyVirtualObject",
handlers: {},
});

const myWorkflow = restate.workflow({
name: "MyWorkflow",
handlers: { run: async () => {} },
});

// <start_lambda>
import * as restate from "@restatedev/restate-sdk/lambda";
export const handler = restate
.endpoint()
.bind(myService)
.bind(myVirtualObject)
.bind(myWorkflow)
// withClass highlight-line
.handler();
// <end_lambda>
4 changes: 2 additions & 2 deletions code_snippets/ts/src/use_cases/async_tasks/fan_out_worker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as restate from "@restatedev/restate-sdk";
import * as restate from "@restatedev/restate-sdk/lambda";
import { Context, CombineablePromise } from "@restatedev/restate-sdk";

// <start_here>
Expand Down Expand Up @@ -35,7 +35,7 @@ const workerService = restate.service({
});

// <mark_3>
export const handler = restate.endpoint().bind(workerService).lambdaHandler();
export const handler = restate.endpoint().bind(workerService).handler();
// </mark_3>
// <end_here>

Expand Down
7 changes: 3 additions & 4 deletions docs/develop/ts/serving.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ CODE_LOAD::ts/src/develop/serving.ts#endpoint

## Creating a Lambda handler

To register your service as a Lambda function, change the endpoint into a Lambda handler:
To register your service as a Lambda function, use the `/lambda` import
component and change the endpoint into a Lambda handler.
```typescript
CODE_LOAD::ts/src/develop/serving.ts#lambda
CODE_LOAD::ts/src/develop/serving_lambda.ts#lambda
```

Have a look at the [deployment section](/category/aws--aws-lambda)
Expand All @@ -41,5 +42,3 @@ for guidance on how to deploy your services on AWS Lambda.
<Admonition type="tip" title={"Run on Lambda without handler changes"}>
The implementation of your services and handlers remains the same for both deployment options.
</Admonition>


3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@
},
"engines": {
"node": ">=18.0"
}
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}

0 comments on commit 8404d18

Please sign in to comment.