Commit Graph
173 Commits
Author SHA1 Message Date
Sébastien Stormacq 7edd4f8108 [core] Fix LocalServer failure to handle large body request (Issue #481) (#504)
Fix https://github.com/swift-server/swift-aws-lambda-runtime/issues/481
2025-06-01 18:31:02 +02:00
Fabian Fett 5924fb6e75 Add inlinable where potentially usefull (#511)
Allow the compiler to specialize more code by applying `@inlinable` to
generic code.
2025-03-21 12:49:08 +01:00
Sébastien Stormacq c3380a0025 [tutorial] fix light image 03-04-01 (#502)
The light mode of image 03-04-01 was not used in the tutorial,
defaulting to dark background all the time.
This is fixed now
2025-03-17 10:56:10 +01:00
Fabian Fett eb634fa9ab Remove unnecessary handler constraints (#499) 2025-03-07 10:31:49 +01:00
Fabian Fett 3ce0a873e3 Attach requestID to logger (#497) 2025-03-07 07:34:05 +01:00
Sébastien Stormacq ae06d59539 cleanup unused code (#498) 2025-03-07 06:48:00 +01:00
Sébastien Stormacq bba711bd18 remove mentions of LambdaRuntImeCore (#495)
Cleanup code from mentions of `LambdaRuntimeCore`
2025-03-06 18:50:32 +01:00
Sébastien Stormacq bf02bcec9a declare user agent string only once (#493)
The user-agent string was repeated at 5+ different places in the source
code.
I defined it as a constant in the `ControlPlaneRequest` struct where
other similar constant have been defined and make sure the rest of the
code only uses that constant.

This should address
https://github.com/swift-server/swift-aws-lambda-runtime/issues/492
2025-03-06 16:52:42 +01:00
Fabian Fett 0a75e0f9cc Use package traits when using Swift 6.1 (#490) 2025-03-06 09:52:23 +01:00
Fabian Fett 03876f6eed [TestServer] Fix 488 and add simple test lambda (#489)
Fixes: #488
2025-03-04 08:20:06 +01:00
61cd5d54da [core] Add cancellation handling for nextInvocation() (#459)
Allow `LambdaChannelHandler.nextInvocation` to be cancelled.

### Motivation:

If we want to use ServiceLifecycle with the lambda runtime the lambda
runtime needs to be cancellable either via a ServiceLifecycle graceful
shutdown or via Task cancellation. To avoid bringing in the
ServiceLifecycle dependency this PR adds cancellation via Task
cancellation handler.

### Modifications:

Add `withTaskCancellationHandler` to nextInvocation which calls close on
cancel.
In `LambdaChannelHandler.channelInactive` resume continuation if state
is `waitingForNextInvocation`
Added `LambdaRuntimeClientTests.testCancellation`

### Result:

You can now cancel the runtime while it is waiting for the next
invocation.

---------

Co-authored-by: Fabian Fett <fabianfett@apple.com>
Co-authored-by: Sébastien Stormacq <sebastien.stormacq@gmail.com>
2025-02-27 17:03:41 +01:00
Fabian Fett 5de00c96c8 Fixes for Local Lambda Server (#486) 2025-02-27 16:08:39 +01:00
Fabian Fett d7780480f2 Enable Swift 6 mode! (#482) 2025-02-20 16:17:23 +01:00
Sébastien Stormacq 7aa746f07e [core] LocalServer - report the error to the continuation (#471)
fix https://github.com/swift-server/swift-aws-lambda-runtime/issues/470
2025-01-22 18:53:57 +01:00
Sébastien Stormacq 02821fe8f7 [test] Update mock server for Swift 6 compliance (#463)
Rewrite to MockServer (used only for performance testing and part of a
separate target) to comply with Swift 6 language mode and concurrency.

The new MockServer now uses `NIOAsyncChannel` and structured
concurrency.

Instead of adding support to
[MAX_REQUEST](https://github.com/swift-server/swift-aws-lambda-runtime/blob/11756b4e00ca75894826b41666bdae506b6eb496/Sources/AWSLambdaRuntimeCore/LambdaConfiguration.swift#L53)
environment variable like v1 did, we implemented support for
`MAX_REQUEST` environment variable in the MockServer itself. It closes
the connection and shutdown the server after servicing MAX_INVOCATIONS
Lambda requests). This allow to add the MAX_REQUEST penalty on the
MockServer and not on the LambdaRuntimeClient.

However, currently, the LambdaRuntimeClient does not shutdown when the
MockServer ends. I created
https://github.com/swift-server/swift-aws-lambda-runtime/issues/465 to
track this issue.

See https://github.com/swift-server/swift-aws-lambda-runtime/issues/377
2025-01-22 12:02:01 +00:00
Sébastien Stormacq ed84609bc4 [core] Update Local Server for Swift 6 compliance (#464)
This PR updates the 4 years old Lambda Local Server for Swift 6
concurrency.

This contributes to
https://github.com/swift-server/swift-aws-lambda-runtime/issues/462
2025-01-22 11:59:10 +00:00
Sébastien Stormacq 752bd41792 move doc images under Resources directory (#460)
Standardize the place where doc resources are located
2025-01-12 17:21:33 +01:00
Sébastien Stormacq 8f7788ffd4 [doc] update deployment guide (#455)
Add a note in the deployment guide to inform Linux user they must have
correct permissions to use docker on their system.

### Motivation:

Build instructions fail on a fresh Ubuntu installation. See this error
report.
https://github.com/swift-server/swift-aws-lambda-runtime/issues/449

### Modifications:

Add a note in the deployment guide that Linux user must add their user
in the `docker` group.

### Result:

Hopefully, Linux users will not experience error at first use of `swift
package archive`
2025-01-06 16:35:06 +01:00
Sébastien Stormacq 2669009d3b Update the tutorial for v2 (#450)
Update the text, code sample, and screenshots for runtime v2

Address
https://github.com/swift-server/swift-aws-lambda-runtime/issues/371
2025-01-04 10:54:37 +01:00
Sébastien Stormacq 430af04828 Update quick-setup.md (#451)
fix typos
2025-01-03 12:28:20 +01:00
Sébastien Stormacq eb9512d053 [doc] update quicksetup guide for v2 (#446)
Update the quick-setup.md docc file to reflect the Runtime v2 API
2025-01-01 21:29:17 +01:00
Sébastien Stormacq f65ec32c4d [doc] add a deployment guide and update the readme (#432)
As discussed with @0xTim 
This PR 
- adds a minimal example of deployment using SAM in the README 
- adds a `Deployment.md` Swift Docc file to cover deployment with the
AWS console, CLI, SAM, and CDK. It mentions and contains a call to
contributions to further examples for third-party tools such as the
Serverless Framework, Terraform, or Pulumi.
2024-12-25 07:43:51 +01:00
Sébastien Stormacq 5ec9a90766 [doc] add 'path: Source' to the quick setup guide (#440)
Fix the `Package.Swift` in the quick setup doc file
This is a follow up and a miss from
https://github.com/swift-server/swift-aws-lambda-runtime/pull/439
2024-12-22 11:16:16 +01:00
Sébastien Stormacq e5404c95cb [examples] Fix path settings in the examples' Package.swift (#439)
All the `Package.swift` files from the examples use `path: "."` instead
of `path: "Sources"` which triggers error messages when users add a
`Tests` directory.
2024-12-22 07:36:32 +01:00
Tobias 25eb6e16de Explicitly only use FoundationEssentials where possible (#436)
We want that the runtime only depends on `FoundationEssentials` where
available (ie. on linux) to ensure small binary size.

### Motivation:

Smaller binary size is good for lambda deployment and cold-start times.
The runtime should only depend on `FoundationEssentials`.

### Modifications:

- replace `import Foundation` with `import FoundationEssentials` if
`FoundationEssentials` is available.
- I also applied the same treatment to tests to ensure that catch error
where tests run on linux and we use API that is only available in
`Foundation` which easily happens when you develop on macOS (where
always full `Foundation` is available).

### Result:

This should allow builds without linking full `Foundation`.
2024-12-20 15:21:33 +01:00
Sébastien Stormacq 23da9bf1ad Ensure LOG_LEVEL is correctly picked up (#435)
Fix issue #434
2024-12-19 18:49:35 +01:00
Sébastien Stormacq 64a4d829f0 Fix CI (#429)
* disable yaml linter

* add semver label check

* re-enable soundness checks (shell, python, and yaml)

* disable checks on docc shell command

* fix errors
2024-11-26 18:32:24 +01:00
Sébastien Stormacq 21e224ea8d Update local server for Swift 6 compliance (#428)
* Update local server to Swift 6

* fix compilation error for local server in release mode

* [CI] fix error for integration plugin test
2024-11-16 10:22:01 +01:00
Sébastien Stormacq 8724c47211 re-enable HTTP server for local testing (#426) 2024-11-14 13:18:01 +01:00
Sébastien StormacqandTim Condon c22f5271a0 add HelloJSON example + README (#424)
* add HelloJSON example + README

* multiple corrections of typos and grammatical errors

Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>
2024-11-13 13:53:19 +01:00
Sébastien Stormacq ca82709a9b Add an example and README for background tasks (#418)
* add an example for background tasks

* swift-format

* add CI

* add background task section in the main readme

* minor formatting changes
2024-11-07 11:33:34 +01:00
Sébastien StormacqandTim Condon 1f80164eb2 add summary + link to API design doc in the readme (#414)
* add summary + link to API design doc in the readme

* typo

Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>

* typo

Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>

---------

Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>
2024-11-07 10:06:30 +01:00
Sébastien Stormacq 7016dfc0fd Set the log level to LOG_LEVEL env variable (#417)
* set the log level to LOG_LEVEL env variable

* remove need for `var logger`

* swift-format

* [ci] update static sdk to 6.0.2
2024-11-07 09:49:11 +01:00
Sébastien Stormacq 4992ba5bd8 change flag name from --allow-network-access to --allow-network-connections as documented by SPM (#407) 2024-10-18 14:51:23 +02:00
aryan-25andFabian Fett 83bd667cce v2 API Proposal Document (#339)
Co-authored-by: Fabian Fett <fabianfett@apple.com>
2024-10-09 10:05:02 +02:00
Fabian Fett a8eadf498e Revert "Use Mutex instead of NIOLockedValueBox (#394)" (#399)
This reverts commit 2c002cc721.
2024-10-09 09:35:14 +02:00
Sébastien Stormacq 053de483f8 Misc small changes to fix CI (#395)
* fix typo

* fix license header

* swift format
2024-10-08 20:29:11 +02:00
Fabian FettandSébastien Stormacq 6d886aa21d Ensure AWSLambdaRuntime only links FoundationEssentials
Co-authored-by: Sébastien Stormacq <sebastien.stormacq@gmail.com>
2024-10-08 19:52:01 +02:00
Fabian FettandSébastien Stormacq 2c002cc721 Use Mutex instead of NIOLockedValueBox (#394)
* Use Mutex instead of NIOLockedValueBox

* fix format

---------

Co-authored-by: Sébastien Stormacq <sebastien.stormacq@gmail.com>
2024-10-08 19:44:56 +02:00
Fabian Fett 4295e51bbb Opt into Swift 6 language mode for most targets (#356)
* Opt into Swift 6 language mode for most targets

* fix parameter order to allow trailing closure syntax
2024-10-08 19:40:12 +02:00
Fabian Fett d2bd7f1aae Fix docs CI (#392) 2024-10-08 17:46:53 +02:00
Sébastien Stormacq f7584d1257 add docker fine grained permission to the plugin (#391)
* add docker fine grained permission to the plugin

* swift-format
2024-10-08 14:10:53 +02:00
Sébastien Stormacq 8131a83bf2 apply swift-format (#380)
* apply swift-format

* use swift-format script from swift-nio project
2024-09-30 22:28:27 +02:00
aryan-25 435033e6a4 Make v2 API functions and types public (#358) 2024-09-05 18:44:01 +02:00
aryan-25 2abd9b5d33 Remove "New" prefix from v2 additions (#357) 2024-09-05 16:00:19 +02:00
aryan-25 85b938e99e Add new LambdaRuntime (#353) 2024-09-05 15:36:30 +02:00
Fabian Fett ddb703946c Remove old API (#355) 2024-09-04 18:28:53 +02:00
Fabian Fett 7a8c0f22c0 New async runtime client (#348) 2024-09-04 15:57:58 +02:00
aryan-25 4b45451dc1 Add new handler protocols + Codable support (#351) 2024-09-04 13:46:00 +02:00
aryan-25andFabian Fett b2da91df46 Add runLoop function (#347)
Co-authored-by: Fabian Fett <fabianfett@apple.com>
2024-09-02 13:53:45 +02:00