You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* First pass of changes to bring README up to date with `master` branch,
preparing for next release
* First round of PR feedback - address typos and `extern crate`
* Apply suggestions from softprops and davidbarsky
Co-authored-by: David Barsky <[email protected]>
* Remove mentions of attribute macro per discussion in PR.
* Return hello functionality to README and referenced example, while leaving custom object handling to later in the document
* Update Deployment to reflect new example behavior
* Suggestion from softprops
Co-authored-by: David Barsky <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+21-65Lines changed: 21 additions & 65 deletions
Original file line number
Diff line number
Diff line change
@@ -4,58 +4,38 @@
4
4
5
5
This package makes it easy to run AWS Lambda Functions written in Rust. This workspace includes multiple crates:
6
6
7
-
-[](https://docs.rs/lambda_runtime_client)**`lambda-runtime-client`** is a client SDK for the Lambda Runtime APIs. You probably don't need to use this crate directly!
8
-
-[](https://docs.rs/lambda_runtime)**`lambda-runtime`** is a library that makes it easy to write Lambda functions in Rust.
7
+
-[](https://docs.rs/lambda)**`lambda`** is a library that provides a Lambda runtime for applications written in Rust.
9
8
-[](https://docs.rs/lambda_http)**`lambda-http`** is a library that makes it easy to write API Gateway proxy event focused Lambda functions in Rust.
10
9
11
10
## Example function
12
11
13
-
The code below creates a simple function that receives an event with a `greeting` and `name`field and returns a `GreetingResponse`message for the given name and greeting. Notice: to run these examples, we require a minimum Rust version of 1.31.
12
+
The code below creates a simple function that receives an event with a `firstName`field and returns a message to the caller. Notice: this crate is tested against latest stable Rust.
14
13
15
14
```rust,no_run
16
-
use std::error::Error;
17
-
18
-
use lambda_runtime::{error::HandlerError, lambda, Context};
The code above is the same as the [basic example](https://github.com/awslabs/aws-lambda-rust-runtime/tree/master/lambda-runtime/examples/basic.rs) in the `lambda-runtime` crate.
34
+
The code above is the same as the [basic example](https://github.com/awslabs/aws-lambda-rust-runtime/blob/master/lambda/examples/hello-without-macro.rs) in the `lambda` crate.
55
35
56
36
### Deployment
57
37
58
-
There are currently multiple ways of building this package: manually, and with the [Serverless framework](https://serverless.com/framework/).
38
+
There are currently multiple ways of building this package: manually with the AWS CLI, and with the [Serverless framework](https://serverless.com/framework/).
59
39
60
40
#### AWS CLI
61
41
@@ -103,7 +83,7 @@ You can now test the function using the AWS CLI or the AWS Lambda console
**Note:**`--cli-binary-format raw-in-base64-out` is a required
@@ -177,34 +157,14 @@ $ unzip -o \
177
157
# Ctrl-D to yield control back to your function
178
158
```
179
159
180
-
## lambda-runtime-client
181
-
182
-
Defines the `RuntimeClient` trait and provides its `HttpRuntimeClient` implementation. The client fetches events and returns output as `Vec<u8>`.
183
-
184
-
For error reporting to the runtime APIs the library defines the `RuntimeApiError` trait and the `ErrorResponse` object. Custom errors for the APIs should implement the `to_response() -> ErrorResponse` method of the `RuntimeApiError` trait.
160
+
## `lambda`
185
161
186
-
## lambda-runtime
162
+
`lambda` is a library for authoring reliable and performant Rust-based AWS Lambda functions. At a high level, it provides a few major components:
187
163
188
-
This library makes it easy to create Rust executables for AWS lambda. The library defines a `lambda!()` macro. Call the `lambda!()` macro from your main method with an implementation the `Handler` type:
164
+
-`Handler`, a trait that defines interactions between customer-authored code and this library.
165
+
-`lambda::run`, function that runs an `Handler`.
189
166
190
-
```rust
191
-
pubtraitHandler<E, O> {
192
-
/// Run the handler.
193
-
fnrun(
194
-
&mutself,
195
-
event:E,
196
-
ctx:Context
197
-
) ->Result<O, HandlerError>;
198
-
}
199
-
```
200
-
201
-
`Handler` provides a default implementation that enables you to provide a Rust closure or function pointer to the `lambda!()` macro.
202
-
203
-
Optionally, you can pass your own instance of Tokio runtime to the `lambda!()` macro:
204
-
```
205
-
let rt = tokio::runtime::Runtime::new()?;
206
-
lambda!(my_handler, rt);
207
-
```
167
+
The function `handler_fn` converts a rust function or closure to `Handler`, which can then be run by `lambda::run`.
208
168
209
169
## AWS event objects
210
170
@@ -215,11 +175,7 @@ This project does not currently include Lambda event struct definitions though w
215
175
To serialize and deserialize events and responses, we suggest using the use the [`serde`](https://github.com/serde-rs/serde) library. To receive custom events, annotate your structure with Serde's macros:
0 commit comments