Expand description
The Lambda runtime core crate implements Lambda’s custom runtime main loop.
The crate receives a Handler
type that consumed events in the form of Vec<u8>
and
outputs a Result
with a Vec<u8>
successful output.
Unless you have specific requirements to consume/produce raw bytes, you should look at the
lambda_runtime
crate.
TODO: Add example
Macros§
- lambda
- Starts an event listener which will parse incoming events into the even type requested by
handler
and will invokehandler
on each incoming event. Can optionally be passed a Tokioruntime
to build the listener on. If none is provided, it creates its own.
Structs§
- Context
- The Lambda function execution context. The values in this struct
are populated using the Lambda environment variables
and the headers returned by the poll request to the Runtime APIs.
A new instance of the
Context
object is passed to each handler invocation. - EnvConfig
Provider - Implementation of the
ConfigProvider
trait that reads the settings from environment variables in the Lambda execution environment. This is the config used by thestart()
method of this module. - Handler
Error - The
HandlerError
struct can be use to abstract anyErr
of the handler methodResult
. TheHandlerError
object can be generatedFrom
any object that supportsDisplay
,Send,
Sync, and
Debug. This allows handler functions to return any error using the
?syntax. For example
let _age_num: u8 = e.age.parse()?;will return the
::Err` from the handler function.
Traits§
- Config
Provider - Trait used by the
RustRuntime
module to retrieve configuration information about the environement. This is implemented by theEnvConfigProvider
using the environment variables. We also have a mock implementation for the unit tests - Handler
- Functions acting as a handler must conform to this type.
- Lambda
Error Ext - The
LambdaErrorExt
trait defines theerror_type()
method used by the AWS Lambda runtime client to generateErrorResponse
objects. The value returned by theerror_type()
method is used to populate theerrorType
field in the Lambda response. This crate includes an implementation of this trait for most errors in the standard library. By default, error return their type name. - Lambda
Result Ext Result
type extension for AWS that makes it easy to generate aHandlerError
object or aCompat<Error>
from the failure crate using an existing result. This trait should be imported from thelambda_runtime_core
orlambda_runtime
crates.
Functions§
- runtime_
release - returns metdata information about the Lambda runtime
- start
- Creates a new runtime and begins polling for events using Lambda’s Runtime APIs.
- start_
with_ config - Internal implementation of the start method that receives a config provider. This method
is used for unit tests with a mock provider. The provider data is used to construct the
HttpRuntimeClient
which is then passed to thestart_with_runtime_client()
function.