Crate lambda_sqs

Source
Expand description

lambda_sqs

Specialised lambda_runtime to accept and process events from SQS.

§SQS Events

SQS dispatches events to the a lambda function in batches (often, it seems to my surprise). This crate provides a lambda_runtime implementation which expects to receive a batch of messages in the SqsEvent type and provides a method to transform the batch of events to a vector of your Struct.

§Example

In Cargo.toml add lambda_sqs as a dependency.

[dependencies]
lambda_sqs = " {0.2.31"
use lambda_sqs::{handler_fn, Context, Error};
use lambda_sqs::SqsEvent;

#[tokio::main]
async fn main() -> Result<(), Error> {
    lambda_sqs::run(handler_fn(my_handler)).await?;

    Ok(())
}

async fn my_handler(e: SqsEvent, c: Context) -> Result<(), Error> {
    let events: Vec<YourStruct> = e.into_t();

Modules§

diagnostic
Diagnostic utilities to convert Rust types into Lambda Error types.
layers
Tower middleware to be applied to runtime invocations.
streaming
Utilities for Lambda Streaming functions.
tower
async fn(Request) -> Result<Response, Error>
tracing
This module provides primitives to work with tracing and tracing-subscriber in Lambda functions.

Structs§

Config
Configuration derived from environment variables.
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.
Diagnostic
Diagnostic information about an error.
LambdaEvent
Incoming Lambda request containing the event payload and context.
LambdaInvocation
A simple container that provides information about a single invocation of a Lambda function.
MetadataPrelude
Metadata prelude for a stream response.
Runtime
Lambda runtime executing a handler function on incoming requests.
SqsEvent
Type that accepts a batch of messages from SQS
StreamResponse
A streaming response that contains the metadata prelude and the stream of bytes that will be sent to the client.

Enums§

FunctionResponse
An enum representing the response of a function that can return either a buffered response of type B or a streaming response of type S.

Traits§

IntoFunctionResponse
a trait that can be implemented for any type that can be converted into a FunctionResponse. This allows us to use the into method to convert a type into a FunctionResponse.
Service
An asynchronous function from a Request to a Response.

Functions§

handler_fnDeprecated
Return a new ServiceFn with a closure that takes an event and context as separate arguments.
run
Starts the Lambda Rust runtime and begins polling for events on the Lambda Runtime APIs.
service_fn
Returns a new ServiceFn with the given closure.

Type Aliases§

Error
Error type that lambdas may result in