Commit Graph
160 Commits
Author SHA1 Message Date
Sébastien StormacqandGitHub 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 StormacqandGitHub 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 StormacqandGitHub 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 StormacqandGitHub 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 StormacqandGitHub 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 StormacqandGitHub 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 StormacqandGitHub 430af04828 Update quick-setup.md (#451)
fix typos
2025-01-03 12:28:20 +01:00
Sébastien StormacqandGitHub 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 StormacqandGitHub 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 StormacqandGitHub 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 StormacqandGitHub 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
TobiasandGitHub 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 StormacqandGitHub 23da9bf1ad Ensure LOG_LEVEL is correctly picked up (#435)
Fix issue #434
2024-12-19 18:49:35 +01:00
Sébastien StormacqandGitHub 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 StormacqandGitHub 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 StormacqandGitHub 8724c47211 re-enable HTTP server for local testing (#426) 2024-11-14 13:18:01 +01:00
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 StormacqandGitHub 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
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 StormacqandGitHub 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 StormacqandGitHub 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
83bd667cce v2 API Proposal Document (#339)
Co-authored-by: Fabian Fett <fabianfett@apple.com>
2024-10-09 10:05:02 +02:00
Fabian FettandGitHub a8eadf498e Revert "Use Mutex instead of NIOLockedValueBox (#394)" (#399)
This reverts commit 2c002cc721.
2024-10-09 09:35:14 +02:00
Sébastien StormacqandGitHub 053de483f8 Misc small changes to fix CI (#395)
* fix typo

* fix license header

* swift format
2024-10-08 20:29:11 +02:00
6d886aa21d Ensure AWSLambdaRuntime only links FoundationEssentials
Co-authored-by: Sébastien Stormacq <sebastien.stormacq@gmail.com>
2024-10-08 19:52:01 +02:00
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 FettandGitHub 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 FettandGitHub d2bd7f1aae Fix docs CI (#392) 2024-10-08 17:46:53 +02:00
Sébastien StormacqandGitHub 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 StormacqandGitHub 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-25andGitHub 435033e6a4 Make v2 API functions and types public (#358) 2024-09-05 18:44:01 +02:00
aryan-25andGitHub 2abd9b5d33 Remove "New" prefix from v2 additions (#357) 2024-09-05 16:00:19 +02:00
aryan-25andGitHub 85b938e99e Add new LambdaRuntime (#353) 2024-09-05 15:36:30 +02:00
Fabian FettandGitHub ddb703946c Remove old API (#355) 2024-09-04 18:28:53 +02:00
Fabian FettandGitHub 7a8c0f22c0 New async runtime client (#348) 2024-09-04 15:57:58 +02:00
aryan-25andGitHub 4b45451dc1 Add new handler protocols + Codable support (#351) 2024-09-04 13:46:00 +02:00
b2da91df46 Add runLoop function (#347)
Co-authored-by: Fabian Fett <fabianfett@apple.com>
2024-09-02 13:53:45 +02:00
aryan-25andGitHub 4121b35ff9 Update LambdaContext (#345) 2024-08-29 11:03:10 +02:00
aryan-25andGitHub 0f68ed5c0c Introduce LambdaRuntimeClientProtocol (#344) 2024-08-28 14:53:02 +02:00
ab8166a39d [CI] Add GHA CI and release flow (#340)
Co-authored-by: Fabian Fett <fabianfett@apple.com>
Co-authored-by: Sébastien Stormacq <sebastien.stormacq@gmail.com>
Co-authored-by: Mahdi Bahrami <github@mahdibm.com>
2024-08-26 16:36:07 +02:00
Sébastien StormacqandGitHub 8676c8933a apply swiftformat (#342)
* apply swiftformat

* update dep on Swift Docc to v1.3.0

* force usage of swift docc plugin 1.3.0
2024-08-26 12:25:41 +02:00
79fa2c2bee [Draft] Detached tasks (#334)
* First prototype

* Fix build

* Removes task cancellation

https://github.com/swift-server/swift-aws-lambda-runtime/pull/334#discussion_r1666713889

* Force user to handle errors

https://github.com/swift-server/swift-aws-lambda-runtime/pull/334#discussion_r1666712903

* Remove EventLoop API

https://github.com/swift-server/swift-aws-lambda-runtime/pull/334#discussion_r1666712244

* Make DetachedTaskContainer internal

https://github.com/swift-server/swift-aws-lambda-runtime/pull/334#discussion_r1666710596
https://github.com/swift-server/swift-aws-lambda-runtime/pull/334#discussion_r1666706576

* Removes @unchecked Sendable

https://github.com/swift-server/swift-aws-lambda-runtime/pull/334#discussion_r1666707646

* Invoke awaitAll() from async context

* Fix ambiguous expression type for swift 5.7

* Fix visibility of detachedBackgroundTask

* Add swift-doc

* Add example usage to readme

* Add tests

---------

Co-authored-by: Sébastien Stormacq <sebastien.stormacq@gmail.com>
2024-08-23 18:50:22 +02:00
Sébastien StormacqandGitHub 872183bbe9 allow compilation with the static linux sdk (musl) (#331) 2024-06-26 10:09:25 +02:00
jsonfryandGitHub 17a993e3b1 Local lambda invocation endpoint env var (#321)
add #321
2024-05-22 14:37:53 +02:00
221978224c Add tracing of request events + mention LOG_LEVEL in README (#315)
* 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>
2024-05-15 09:56:35 +02:00
tomer doronandGitHub 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
2024-01-18 13:48:10 -08:00
tomer doronandGitHub 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
tachyonicsandGitHub 0fbd8448af Don't log work fetching failure at error. (#313) 2023-12-08 12:49:03 -08:00
Sébastien StormacqandGitHub c85c875593 [doc] Getting Started documentation and tutorial (#300)
improved getting started documentation, with DocC
2023-09-11 10:43:06 -07:00
tomer doronandGitHub 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