# Mayfly v1.0.0-rc.1 - API Reference

## Modules

- Writing functions
  - [Mayfly.Context](Mayfly.Context.md): Per-invocation metadata, built from the `GET /runtime/invocation/next`
response headers and passed as the second argument to `c:Mayfly.Handler.handle/3`.
  - [Mayfly.ErrorPayload](Mayfly.ErrorPayload.md): Builds the error document Lambda expects on `/runtime/invocation/<id>/error`
and `/runtime/init/error`
  - [Mayfly.Handler](Mayfly.Handler.md): Behaviour for Lambda function handlers.
  - [Mayfly.Response](Mayfly.Response.md): What a handler may return inside `{:ok, _}`.

- Event sources
  - [Mayfly.Events](Mayfly.Events.md): Typed decoders for the event shapes AWS services send to Lambda.
  - [Mayfly.Events.DynamoDB](Mayfly.Events.DynamoDB.md): Amazon DynamoDB Streams events.
  - [Mayfly.Events.DynamoDB.Record](Mayfly.Events.DynamoDB.Record.md): One stream record.
  - [Mayfly.Events.EventBridge](Mayfly.Events.EventBridge.md): Amazon EventBridge events (custom events, scheduled rules, AWS service events).
  - [Mayfly.Events.HTTP](Mayfly.Events.HTTP.md): HTTP events from API Gateway (REST v1 and HTTP v2), Lambda Function URLs
(v2 shape) and Application Load Balancer, plus helpers that build the
proxy response each of them expects.
  - [Mayfly.Events.HTTP.Request](Mayfly.Events.HTTP.Request.md): A decoded HTTP request. See `Mayfly.Events.HTTP`.
  - [Mayfly.Events.Kinesis](Mayfly.Events.Kinesis.md): Amazon Kinesis Data Streams events.
  - [Mayfly.Events.Kinesis.Record](Mayfly.Events.Kinesis.Record.md): One Kinesis record.
  - [Mayfly.Events.S3](Mayfly.Events.S3.md): Amazon S3 event notifications.
  - [Mayfly.Events.S3.Record](Mayfly.Events.S3.Record.md): One S3 notification record.
  - [Mayfly.Events.SNS](Mayfly.Events.SNS.md): Amazon SNS notifications delivered directly to Lambda.
  - [Mayfly.Events.SNS.Record](Mayfly.Events.SNS.Record.md): One SNS notification.
  - [Mayfly.Events.SQS](Mayfly.Events.SQS.md): Amazon SQS events.
  - [Mayfly.Events.SQS.Record](Mayfly.Events.SQS.Record.md): One SQS message.

- Runtime
  - [Mayfly](Mayfly.md): Mayfly – an AWS Lambda custom runtime for Elixir.
  - [Mayfly.Boot](Mayfly.Boot.md): Entry point used by the generated `bootstrap` script
  - [Mayfly.HTTP](Mayfly.HTTP.md): Minimal HTTP/1.1 client over `:gen_tcp` for the link-local Lambda Runtime API.
  - [Mayfly.Poller](Mayfly.Poller.md): One poller owns one concurrency slot: it long-polls `/runtime/invocation/next`,
runs the handler and posts the result, then polls again.
  - [Mayfly.RuntimeAPI](Mayfly.RuntimeAPI.md): Client for the [Lambda Runtime API](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html)
(version 2018-06-01), built on `Mayfly.HTTP`.
  - [Mayfly.Supervisor](Mayfly.Supervisor.md): Starts one `Mayfly.Poller` per concurrency slot after the handler has been
resolved and initialised exactly once.

- Observability
  - [Mayfly.Extension](Mayfly.Extension.md): Internal Lambda extension: registers with the Extensions API, subscribes to
the Telemetry API, and turns platform telemetry into `:telemetry` events.
  - [Mayfly.LogFormatter](Mayfly.LogFormatter.md): Logger formatter that emits one JSON object per line in the shape Lambda's
[advanced logging controls](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs-advanced.html)
expect, so CloudWatch parses level, request id and tenant id
  - [Mayfly.Metrics](Mayfly.Metrics.md): CloudWatch metrics without API calls, using the
[Embedded Metric Format](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format_Specification.html):
one JSON line on stdout that CloudWatch Logs turns into metrics.
  - [Mayfly.Shutdown](Mayfly.Shutdown.md): Graceful shutdown on `SIGTERM`.
  - [Mayfly.Telemetry](Mayfly.Telemetry.md): Telemetry events emitted by the runtime. `:telemetry` is an optional
dependency; when it is not present the calls are no-ops.

- Build &amp; local dev
  - [Mayfly.LocalRuntime](Mayfly.LocalRuntime.md): A small Lambda Runtime API emulator for local development and tests.
  - [Mayfly.Release](Mayfly.Release.md): Turns `mix release` into a Lambda package builder.

## Mix Tasks

- [mix lambda.doctor](Mix.Tasks.Lambda.Doctor.md): Runs a set of checks that catch the common setup mistakes before you deploy
- [mix lambda.new](Mix.Tasks.Lambda.New.md): Generates a new Elixir project that builds and deploys as an AWS Lambda
function with Mayfly.

- Build &amp; local dev
  - [mix lambda.build](Mix.Tasks.Lambda.Build.md): Builds the Lambda package for a release configured with `Mayfly.Release`:
a `lambda.zip` (copied to `--outdir`) or, with `--image`, a container image
for Lambda's image package type.
  - [mix lambda.invoke](Mix.Tasks.Lambda.Invoke.md): Runs your handler exactly as Mayfly would inside Lambda – handler
resolution, `init/1`, JSON decoding, context, error formatting – against
`Mayfly.LocalRuntime`, and prints the response or error.

