86 Commits
Author SHA1 Message Date
Donald NessandGitHub 699ada1724 Add guards for code that relies on _Concurrency (#237)
This allows Xcode 13 to still compile on macOS 11 which does not have symbols for Concurrency yet
See swift-server/swift-service-lifecycle#110
2021-10-04 17:20:07 -07:00
Cory BenfieldandFabian Fett dc37adebe7 Clean up dependency graph and imports (#218)
- Correctly express the dependency on NIO in Package.swift
- Correctly import _NIOConcurrency in files where it's used
2021-08-24 17:37:21 +02:00
Joel SaltzmanandFabian Fett f9d10b2fdc Renamed completeWithAsync to completeWithTask (#221)
* Renamed EventLoopPromise's `completeWithAsync` to `completeWithTask` (based on the SwiftNIO renaming)
* Updated swift-nio dependency to 2.32.0
2021-08-24 17:36:39 +02:00
Fabian FettandGitHub a9e15b13b3 Fix platform requirements (#214)
- Replace the placeholder platform requirements with `@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)` 
- Bump required dependency versions: `swift-nio`, `swift-log` and `swift-backtrace`
2021-07-21 20:47:35 +02:00
DwayneCoussementandGitHub 9a7d9d0941 SNS MessageAttributes are optional (#208)
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
2021-06-11 10:14:48 -07:00
19fc295aa0 async/await support (#186)
- 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>
2021-04-27 22:47:11 +02:00
MLandGitHub edbfa795b6 Updated S3.Event (#195)
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
2021-04-15 10:35:08 -07:00
Fabian FettandGitHub 19a9f92538 Inline default LambdaHandler implementations (#201)
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.
2021-04-14 22:59:42 +02:00
Fabian FettandGitHub ab13e51984 Performance Improvements (#199)
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`.
2021-04-14 00:21:38 +02:00
Fabian FettandGitHub a49a87341a Update swiftformat (#196)
changes: 
* Update swiftformat from 0.44 to 0.47
* Adjust rules
2021-03-26 10:34:34 -07:00
DwayneCoussementandGitHub e33e4afbf0 Add support for AppSync events. (#187)
motivation: Support AWS AppSync events
changes: add Codable models for AppSync events
2021-03-02 13:05:50 -08:00
Ralph KüpperandGitHub ee2a6e0cb3 Fix the queryStringParameters in ALB.TargetGroupRequest. (#182) 2021-01-06 09:16:51 +01:00
f51eeb6c84 Fixed the visibility of the JWT in an API Gateway V2 Request. (#178)
Co-authored-by: Johannes Bosecker <johannes@Johanness-MacBook-Air.local>
2020-12-07 16:54:03 +09:00
Fabian FettandGitHub edef0363b6 updates to APIGateway V2 payloads
* Properties of HTTPResponses are now var (#176)
* remove redundant multiValueHeaders
2020-10-13 15:02:45 -07:00
Filipp FediakovandGitHub 0afbf42226 Fix typo in LambdaRunner.swift documentation (#171) 2020-09-25 18:12:09 +02:00
tomer doronandGitHub 8986809d8e simplify date formatting (#159)
motivation: use consistent date formatting across platforms

changes: use manually configured DateFormatter instead of ISO8601DateFormatter
2020-08-14 14:24:29 -07:00
tomer doronandGitHub f731664c4d remove requirment on macOS 10.13 (#156)
motivation: simplify downstream libraries

changes: precondition out debugging uses cases on macOS < 10.13
2020-08-10 10:02:12 -07:00
tomer doronandGitHub f3c68d66c4 better error message when invoking local lambda server with incorrect http method (#157)
motivation: nicer error messages

changes: return 405 when using wrong http method on the lambda invocatoin endpoint (local debug server)
2020-08-06 14:39:32 -07:00
tomer doronandGitHub 9ebc9dda20 give better error when lambda fails to start (#155)
motivation: in error cases where lamnda fails to start the process fails silently and exists with code 0

changes: change the blocking API to check on the result and fatalError if lambda cannot be started / run
2020-08-06 14:08:25 -07:00
2067f4aea1 JSONEncoder/JSONDecoder and String convenience methods (#144)
Co-authored-by: Konrad `ktoso` Malawski <konrad.malawski@project13.pl>
2020-08-03 21:04:13 +02:00
pokryfkaandGitHub 1b594cad62 Generate trace ID in correct format (#139)
motivation: more correct Xray TraceID

changes:
* add AmazonHeaders::generateXRayTraceID
* Generate correct trace ID in LocalLambda Server
* Generate correct trace ID in LambdaRuntimeClientTest
2020-07-07 18:53:25 -07:00
Adam FowlerandGitHub 5130278087 SES time zone (#135)
motivation: Sometimes common header date comes with an alphabetical timezone in brackets after the numeric timezone

changes:
* Support common header date format with brackets
* Update readme with SES Event link
2020-06-27 13:16:52 -07:00
tomer doronandGitHub 2bac89639f add syncShutdown to LambdaHandler (#132)
motivation: make shutdown easier to use

changes:
* override shutdown to use the offloadQueue to perform syncShutdown
* add empty syncShutdown that can be implmented by the concrete Lambda function
2020-06-18 12:48:13 -07:00
Adam FowlerandGitHub d2f5c1c324 Added SES Event type (#130)
motivation: support event triggers from SES

changes: Added SES Event type
2020-06-17 09:53:53 -07:00
Fabian FettandGitHub 437a60d7a0 Added shutdown() -> EventLoopFuture<Void> to the ByteBufferLambdaHandler (#122)
* Added `syncShutdown() throws` to the `ByteBufferLambdaHandler`

* Updated to use a `ShutdownContext`

* Review comments addressed.
2020-06-17 07:34:01 -07:00
Ro-MandGitHub 77280662e3 Added header when reporting failing invocations or initializations #116 (#128)
* allow the users of client to provide headers
* add initialization error header
* add error header to failed invocations
* fix external setting of ip and port via config
* add tests
2020-06-17 06:55:05 -07:00
tomer doronandGitHub d1a927650a add initialization context (#126)
motivation: in more complex initialization scearios you may want access to a logger or other utilities

changes:
* introduce new InitializationContext type that could be extended in the future without breaking the API in semantic-major way
* instead of passing in EventLoop to the handler factory, pass in a context that includes a Logger, an EventLoop and a ByteBufferAllocator
* fix a bug where we dont hop back to the event loop when coming back from the handler
* adjust tests to the new signature
2020-06-16 11:08:00 -07:00
Fabian FettandGitHub 0008e59bab Rename payload to event (#115) 2020-06-07 07:47:05 -07:00
tomer doronandGitHub 3b29513652 handle lambda errors correctly in mock server (#104)
motivation: better mock server

changes:
* add handler for :requestID/error
* return .accepted to lambda
* return .internalServerError to client + error json
* small refactoring of response code in mock server to make it DRYer
2020-06-01 13:15:30 -07:00
tomer doronandGitHub e2ac820289 add an option to start the local debugging server based on an env variable (#87)
motivation: make using the local debugging server easier to turn off/on without the need to change code when oyu are preparing to deploy

changes:
* add code to lambda so that in debug mode only, if the LOCAL_LAMBDA_SERVER_ENABLED env variable is set the local debugging server is started
* make withLocalServer internal
* update example code
2020-06-01 12:38:06 -07:00
Bryan MoffattandGitHub eaa6fb6338 Add a User-Agent when using the Lambda Runtime API (#98)
* Add a User-Agent when using the Lambda Runtime API
2020-05-30 10:39:34 -07:00
tomer doronandGitHub 8c24cffd97 fix context members to follow swift APi guidelines (#88)
motivation: nicer API

changes:
* requestID -> requestID
* traceId -> traceID
* invokedFunctionArn -> invokedFunctionARN
* adjust examples
2020-05-27 11:46:31 -07:00
Fabian FettandGitHub fe60959b99 fix race condition when shutting down server
motivation: fix a race condition that can lead to crash and failing tests

changes: close channel when canceling
2020-05-21 09:11:29 -07:00
53930fef38 add debug functionality to test with mock server (#73)
motivation: allow end to end testing locally

changes:
* add a Lambda+LocalServer which exposes Lambda.withLocalServer available only in DEBUG mode
* local server can receive POST requests with payloads on a configurable endpoint and and send them to the Lambda
* move Lifecycle completely into EventLoop
* remove all locks since running in one EventLoop
* Use UUID for requestId

Co-authored-by: tom doron <tomer@apple.com>
2020-05-15 16:56:17 -07:00
ab3ce640aa Use NIO in Single Threaded Mode (#68)
motivation: better performance 

changes:  employ SwiftNIO's new Single Threaded Mode

Co-authored-by: tomer doron <tomerd@apple.com>
2020-05-12 13:41:10 -07:00
Fabian FettandGitHub b7462b8081 Make Lambda.env() -> String? public (#61) 2020-05-08 12:35:55 -07:00
Fabian FettandGitHub 1d9637279a Moved Foundation to AWSLambdaRuntime; AWSLambdaRuntime renamed to AWSLambdaRuntimeCore (#41)
motivation: enable non-foundation module for performance sensitive use cases

changes: 
* rename AWSLambdaRuntime to AWSLambdaRuntimeCore 
* create AWSLambdaRuntime for Foundation dependent functionality 
* have (new) AWSLambdaRuntime export AWSLambdaRuntimeCore
* adjust tests
2020-05-07 09:37:28 -07:00
Fabian FettandGitHub 29d631709f Added DynamoDB Event (#65)
motivation: support DynamoDB triggers

changes: added DynamoDB Event abstractions and encoders/decoders
2020-05-07 09:05:11 -07:00
Fabian FettandGitHub 9df8a1a468 Rename RequestWork to GetNextInvocation (#74) 2020-05-07 08:37:07 -07:00
tomer doronandGitHub 593f0395d6 better links to events docs (#67)
motivation: link to developer guide instead of golang impl

changes: add/change event doc links to https://docs.aws.amazon.com/lambda/latest/dg/lambda-services.html
2020-05-06 07:23:54 -07:00
tomer doronandGitHub 2324074c33 improve type aliases and API docs (#64)
motivation: better documentation, happier users

changes: 
* add more information on public APIs
* move and simplify type aliases
2020-04-28 14:31:43 -07:00
Fabian FettandGitHub 8509674ed0 Add apigateway and alb (#52)
motivation: support ALB and APIGateway Events

changes: add Codable abstractions for ALB and APIGateway v1+v2  Events
2020-04-27 10:49:44 -07:00
Fabian FettandGitHub 2297929bfd LambdaCodableEncoder should be less Foundation biased (#66) 2020-04-27 10:32:17 -07:00
tomer doronandGitHub bfad18623d hide testing harness in release builds (#63)
motivation: testing harness should only be used for testing, and uses @testable import which doe not work in release builds

changes: hide code behind #if check
2020-04-27 10:23:56 -07:00
Fabian FettandGitHub 920302a4c3 Improve testing utils (#60)
motivation: make testing lambda easy

changes:
* add a AWSLambdaTesting module
* add helper methods for testing different types of Lambda handlers / closures
2020-04-23 00:11:05 -07:00
Fabian FettandGitHub 378adf844d Allow integration with API Frameworks: Public Lifecycle (#58)
motivation: easy integration of web frameworks frameworks like vapor and smoke

changes: expose `Lifecycle` as a public API to allow easy integration with higher level frameworks
2020-04-22 16:10:38 -07:00
Fabian FettandGitHub 7a946064e7 Added SNS & SQS Events (#46)
* Added SNS & SQS Events
* Added Base64 util
2020-04-03 10:36:47 -07:00
Fabian FettandGitHub a810911e02 AWSRegion without enum (#54) 2020-04-03 10:34:23 -07:00
Fabian FettandGitHub 3fad2f5751 Added Cloudwatch Event (#48)
motivation: support cloud watch events

changes: 
* add aws region abstraction
* add generic cloud watch abstraction 
* add common / key cloud watch events
2020-03-30 14:07:18 -07:00
Fabian FettandGitHub 6f7103251a Reusable JSONCoders (#50)
motivation: beter performance

changes: 
* abstract JSONCoders and have a default static instance
* make encoding/decoding DRYer across String and Codable
2020-03-27 09:21:42 -07:00