Commit Graph
203 Commits
Author SHA1 Message Date
tomer doron 8d9f44b783 allow custom initialization of the HandlerType of the LambdaRuntime (#310)
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
1.0.0-alpha.2
2024-01-18 13:48:10 -08:00
Sébastien Stormacq c4f380e21c Include the docc tutorial into 1.0.0 (#316)
Improved getting started documentation, with DocC
2023-12-18 12:16:44 -08:00
tomer doron 42eaaf4fb1 remove redundant pre-concurrency flag (#314)
motivation: address warnings

changes:
* remove pre-concurrency flag when not longer needed
2023-12-18 11:49:03 -08:00
tachyonics 0fbd8448af Don't log work fetching failure at error. (#313) 2023-12-08 12:49:03 -08:00
Florent Morin 2c3b2451db Add --disable-docker-image-update plugin flag (#311)
motivation: sometimes, you need to use a customized local docker image and `docker pull` don’t have to be called

changes:
* add `--disable-docker-image-update` plugin flag to disable `docker pull` call
2023-12-01 11:27:41 -08:00
tomer doron f3eac3167a add 5.10 ci setup (#309)
motivaiton: test for upcoming 5.10 release

changes: add docker setup for stable 5.9 and nightly 5.10
2023-10-10 14:36:19 -07:00
Sébastien Stormacq c85c875593 [doc] Getting Started documentation and tutorial (#300)
improved getting started documentation, with DocC
2023-09-11 10:43:06 -07:00
Sébastien Stormacq 5d300b2e1b ignore swift files part of docc (#307) 2023-09-11 09:30:19 -07:00
tomer doron e221dd8362 remove swift-backtrace in swift >= 5.9 (#305)
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
2023-09-07 18:39:11 -07:00
tomer doron e7751d0afb update code of conduct (#303)
motivation: align CoC across the swift project

changes: change CoC to link to the swift.org version
2023-06-06 10:28:39 -07:00
Joannis Orlandos 8e0eae1202 Fix a dead tutorial link (#301) 2023-04-18 09:28:43 -07:00
Yim Lee 50c4ec90a5 Swift 5.8 docker images are available (#298)
* Swift 5.8 docker images are available

* Add docker-compose file for Swift 5.9

* Fix image name
2023-04-04 14:47:56 -07:00
tomer doron 3b72f6a6cf improve examples (#292)
motivation: examples can be confusing since they use relative path to the library for CI purposes

changes:
* update examples to use the library URL, expect when env variable is set for CI purposes
* rename docker compose job to test-examples since it is more accurate
2023-03-12 11:23:41 -07:00
Adolfo fb860605a8 Issue template v2 (#290)
Use issue Report v2: Issue template using the GitHub Forms syntax.
2023-02-23 09:10:58 -08:00
Adolfo 5dc0da0e30 Archive plugin documentation (#287)
Improve archive command documentation 

* Show the options that the new `archive` plugin provides to customize the operation behavior.
* Provide an example with the `archive` command taking two parameters
2023-02-22 09:48:30 -08:00
Adolfo 81762b0e45 Change the SQS.Event to the valid SQSEvent type at the SimpleLambdaHandler example (#286) 2023-02-09 00:27:54 -08:00
tomer doron 735c49f28d add docker compose setup for swift 5.8 (#284)
motivation: prepare for swift 5.8

changes: add docker compose setup for nightly 5.8
2023-01-25 18:47:27 -08:00
Camden Fullmer 58664bd23b Add note about naming the file main.swift. (#283) 2023-01-17 16:41:36 -08:00
tomer doronandYim Lee de730b240d udpate readme to reflect 1.x API (#281)
motivation: prepare documentation in preparation for 1.x release

changes: update readme with  1.x APIs

Co-authored-by: Yim Lee <yim_lee@apple.com>
1.0.0-alpha.1
2023-01-12 09:50:25 -08:00
tomer doron a5fb165f65 fix concurrency api usage (#282)
motivation: cleanup incorrect concurent code in test

changes: use .get instead of .wait
2023-01-10 16:24:11 -08:00
Yim Lee dc64ce195b Add .spi.yml for Swift Package Index DocC support (#274) 2022-12-04 09:28:25 -08:00
c915322eca API Refactoring (#273)
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>
2022-11-09 10:08:36 -08:00
Yim Lee 98a23b64bb DocC setup (#270) 2022-08-21 20:29:08 -07:00
sja26 568897c8b7 Update readme (#269)
* Fix compiler warning

'MyLambda' was identified as an executable target given the presence of a 'main.swift' file. Starting with tools version 5.4.0 executable targets should be declared as 'executableTarget()'

* Fix package dependency for swift-aws-lambda-events

The swift-aws-lambda-events repo has not yet pushed tag 0.1.0 so the build fails, see output from swift build:

Computing version for https://github.com/swift-server/swift-aws-lambda-events.git
error: Dependencies could not be resolved because no versions of 'swift-aws-lambda-events' match the requirement 0.1.0..<1.0.0 and root depends on 'swift-aws-lambda-events' 0.1.0..<1.0.0.

This commit adds the workaround mentioned in the issue for the missing tag https://github.com/swift-server/swift-aws-lambda-events/issues/3

* Fix multiple products and targets build error
2022-08-11 10:16:03 -07:00
YR Chen cb340de265 Fix performance test script (#264) 2022-06-06 09:39:40 -07:00
81f8d27365 packaging plugin (#254)
motivation: add an easy wasy for lambda users to package their lambda and upload it to AWS

changes:
* add SwiftPM plugin to package the lambda as zipfile, with the verb "archive"
* use docker to build and package the lambda(s) on macOS and non-amazonlinux
* build directly on when on amazonlinux, zip correctly

Co-authored-by: Yim Lee <yim_lee@apple.com>
Co-authored-by: Fabian Fett <fabianfett@apple.com>
2022-06-01 09:41:05 -07:00
Bill 20978cc462 Add special Deployment instructions for the Mac M1 (#263) 2022-05-09 10:19:30 -07:00
Fabian Fett ac52960abd Initialize LambdaRuntime with concrete HandlerType + Docu fixes (#260) 2022-04-20 22:14:03 +02:00
Fabian Fett cebcf04d23 Drop Swift 5.2 and 5.3 (#262)
As outlined in a [Swift forums post in November ’21](https://forums.swift.org/t/swiftnio-swift-version-support/53232), SwiftNIO will only support the latest non-patch Swift release and the 2 immediately prior non-patch versions.
2022-04-20 22:02:24 +02:00
Fabian Fettandtomer doron f6c7c5a852 Add script to check for API breaks (#258)
Co-authored-by: tomer doron <tomer@apple.com>
2022-04-15 10:36:12 -07:00
tomer doron e5b44962bd Prefix data structures with Lambda instead of namespacing them (#256)
motivation: consisten naming convention

changes:
* Lambda.InitializationContext -> LambdaInitializationContext
* Lambda.Runner -> LambdaRunner
* Lambda.Configuration -> LambdaConfiguration
* Lambda.RuntimeError -> LambdaRuntimeError
* adjust call sites, tests, and examples
2022-04-15 13:33:54 +02:00
tomer doron d35e827121 Remove extension for JSONEncoder and JSONDecoder (#257)
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
2022-04-15 13:05:49 +02:00
tomer doron 3c3529b4dc adoption of sendable (#252)
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
2022-04-14 09:39:00 -07:00
tomer doron 4d0bba4617 termination handler (#251)
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
2022-04-13 12:16:26 -07:00
tomer doron f2a0ef59ac fix docker compose shell task (#253)
motivation: make it easier to shell into interactive session

changes: pass -l flag to bash to inherit PATH
2022-03-17 22:15:16 -07:00
tomer doron 51c27f9b0e ci update (#249)
motivation: 5.6 is out

changes:
* use release version of 5.6
* add docker setup for 5.7 (using nightly for now)
2022-03-16 21:15:31 -07:00
Stefan Nienhuis c1f694f35a Add default value for traceID header (#246)
* Add default value for traceID header
* Implement Invocation traceID test
2022-02-19 14:16:51 -08:00
Fabian Fett d06d22c0e0 Lambda factory as a protocol requirement. (#244) 2022-01-13 19:10:20 +01:00
Fabian Fett 5d235c0a3b Add ControlPlaneRequestEncoder (#239)
Add a new `ControlPlaneRequestEncoder` that encodes all control plane requests into an existing, reused buffer.
2021-12-11 13:35:57 +01:00
Fabian Fett bc78f60e32 Add LambdaRequestID (#243)
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).
2021-12-11 13:05:48 +01:00
Fabian Fett b8d89ca208 Add ControlPlaneRequest, ControlPlaneResponse (#238)
### 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`
2021-12-06 21:17:38 +01:00
YR Chen 4317c5334f Adopt concurrency adoption guidelines (#230)
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
2021-12-06 20:52:35 +01:00
YR Chen 39b34a159b Modernize app example (#231)
Since we already required Swift 5.5 for Concurrency (Xcode 13), it's natural to update the demo app to reflect latest SwiftUI changes, which makes the code neater and more expressive.
2021-12-06 11:30:50 +01:00
Fabian Fett 011e8ddc4b Rename Lambda.Context to LambdaContext (#233) 2021-09-30 01:56:58 +02:00
Fabian Fett afab5102a1 Rename Lambda.Lifecycle to LambdaRuntime (#232) 2021-09-29 09:10:30 +02:00
tomer doron b757de0241 Update and add examples to new APIs (#228)
* 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
2021-09-25 10:30:04 +02:00
Fabian Fett 7c1dea035d Remove dependency on _NIOConcurrency (#229) 2021-09-23 19:44:08 +02:00
tomer doron 5a21193ea6 Use release version of 5.5 in CI (#227)
motivation: 5.5 release is available

changes: update docker CI setup to use the release version of 5.5
2021-09-22 12:12:32 -07:00
Fabian Fett e5aa488a26 [RFC] Drop event label from handle methods in LambdaHandlers (#225)
* Drop event label from handle method in LambdaHandlers
* Rename `In` to `Event` and `Out` to `Output` in `EventLoopLambdaHandler`
2021-09-22 16:59:07 +02:00
Fabian Fett dbd675df6f Reorder Event and Context. (#224)
motivation: follow API design guidelines

changes: Reorder `event` and `context` n public APIs
2021-08-24 15:26:39 -07:00