* add tracing of request events + mention LOG_LEVEL in README
* fix typo
Co-authored-by: Mahdi Bahrami <github@mahdibm.com>
* clarify the use of env variable and the swift cli
Co-authored-by: Mahdi Bahrami <github@mahdibm.com>
* clarify language about HTTP server
Co-authored-by: Mahdi Bahrami <github@mahdibm.com>
* formatting
Co-authored-by: Mahdi Bahrami <github@mahdibm.com>
* factor in additional suggestions from @mahdibm
* combine two logger statement into one and print only for Kb of payload
---------
Co-authored-by: Mahdi Bahrami <github@mahdibm.com>
Motivation:
Provide the flexibility for custom initialization of the HandlerType as this will often be required by higher level frameworks.
Modifications:
* Modify the LambdaRuntime type to accept a closure to provide the handler rather than requiring that it is provided by a static method on the Handler type
* Update downstream code to use HandlerProvider
* Update upstream code to support passing Handler Type of Handler Provider
* Add and update tests
Originally suggested and coded by @tachyonics in https://github.com/swift-server/swift-aws-lambda-runtime/pull/308
motivation: swift 5.9 ships with builtin backtrace support \o/
changes:
* remove the dependency on swift-backtrace when using swift 5.9 or above
* conditionalize the call to Backtrace.install to relevant versions only
motivation: define stable API in preperation 1.0 release
changes:
* require swift 5.7, remove redundant backwards compatibility code
* make LambdaHandler, EventLoopLambdaHandler, and ByteBufferLambdaHandler disjointed protocols to reduce API surface area
* create coding wrappers for LambdaHandler and EventLoopLambdaHandler to provide bridge to ByteBufferLambdaHandler
* reuse output ByteBuffer to reduce allocations
* add new SimpleLambdaHandler with no-op initializer for simple lambda use cases
* update callsites and tests
* update examples
Co-authored-by: Yim Lee <yim_lee@apple.com>
Co-authored-by: Fabian Fett <fabianfett@apple.com>
motivation: we should not publicly extend types we do not own
change: remove extensions which are largely API sugar that is not directly related to Lambda
motivation: adopt to sendable requirments in swift 5.6
changes:
* define sendable shims for protocols and structs that may be used in async context
* adjust tests
* add a test to make sure no warning are emitted
motivation: make it simpler to register shutdown hooks
changes:
* introduce Terminator helper that allow registering and de-registaring shutdown handlers
* expose the new terminator hanler on the InitializationContext and deprecate ShutdownContext
* deprecate the Handler::shutdown protocol requirment
* update the runtime code to use the new terminator instead of calling shutdown on the handler
* add and adjust tests
If we want to minimize allocations for every invocation, we need to look at types that currently allocate. Currently we use a String to hold the request id. However since the request id is a uuid, that string is 36 characters long. This is way above the 15 character string allocation threshold. The go to type in this case would be `UUID`. However `UUID` is in Foundation and we want to keep the lambda runtime Foundation free.
This pr introduces a LambdaRequestID to represent a uuid. One nice side effect of having our own uuid case is: We can make writing the uuid-string to a ByteBuffer allocation free (since no intermediate translation to a string is needed first).
### Motivation:
In the coming weeks, we want to restructure the LambdaRuntime internals in such a way, that we allocate a lot less resources per invocation. To accomplish this, we want to encode and decode the ControlPlaneAPI requests directly from their semantic value. For this reason, we need a specialized ControlPlaneRequest and ControlPlaneResponse type that we can encode from and decode into.
### Modifications:
- Add `ControlPlaneRequest`, `ControlPlaneResponse`
- Move `Invocation` and `ErrorResponse` into same file as `ControlPlaneRequest`
- Remove `Lambda` namespace around `Invocation`
Adopt Swift Concurrency adoption guidelines for Swift Server Libraries (swift-server/guides#70).
- Use #if compiler(>=5.5) && canImport(_Concurrency) to judge if Concurrency is available
- Some clean up
* take advantage of @main where possible
* move the top level Sample code to the examples subdirectory
* extract a few examples form the "LambdaFunctions" directory (which is really a deployment demo) and move them to the top level Examples directory
* rename "LambdaFunctions" examples as "Deployments" to make their intent clearer
* add a sample that demonstrates how to test a lambda now that SwiftPM can test executables directly
* update the test-sample docker setup to build & test th new samples
* fix a few typos and In/Out typealias left overs
* remove LinuxMain since its no longer required
motivation: with async/await, no need in closure based APIs
changes:
* Drop closure APIs
* Rename AsyncLambdaHandler -> LambdaHandler
* Removed unnecassary public acls from tests
motivation:
the runtime library has a stable API while the events are still moving target. In order to provide a 1.0 stable version we separate them out
changes:
* remove Events module
* update readme
* update Samples
* remove gateway example
Co-authored-by: Fabian Fett <fabianfett@apple.com>
Motivation: Lambda.Context is currently a class that only holds values. For this reason it should be a value type itself.
Changes: Lambda.Context is now a struct, that is backed by a CoW storage class, to ensure performance remains high.
motivation: Notice that if you check the contents of the SQS records, some kind of transform happened on the original SNS message. MessageAttributes in the above example, these will not be set, so this is the initial fix.
changes: make MessageAttributes are optional
- Add an `AsyncLambdaHandler`. Will be renamed to `LambdaHandler` as soon as we drop the current callback based `LambdaHandler`.
- The default way to use an `AsyncLambdaHandler` is to use `@main` to execute it. Don't use `Lambda.run` for it. We wan't to remove `Lambda.run` for 1.0.
Co-authored-by: tomer doron <tomerd@apple.com>
motivation: support s3:ObjectRemoved:* event
changes:
* Changed the S3.Event object size field to an optional due to the missing field on a s3:ObjectRemoved:* event
* Added one additional test to check propper json decoding
Add `@inlinable` to default LambdaHandler implementations. This ensures that those implementations can be inlined into user code and can be specialized for their input and output types.
Modifications:
- Replace `HTTPHandler` with `NIOHTTPClientResponseAggregator`, to fix a CoW issue. This increases performance.
- Ensure that we only use one `EventLoop` in tests.
- Use `syncOperations` to setup the `HTTPClient`.