20 Commits

Author SHA1 Message Date
tomer doron 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
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 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
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
Fabian Fett 011e8ddc4b Rename Lambda.Context to LambdaContext (#233) 2021-09-30 01:56:58 +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
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
Fabian Fett 454fe2e037 Drop sync and closure APIs (#222)
motivation: with async/await, no need in closure based APIs

changes:
* Drop closure APIs
* Rename AsyncLambdaHandler -> LambdaHandler
* Removed unnecassary public acls from tests
2021-08-24 14:20:13 -07:00
Fabian Fett f01a9b607b Use explicit NIO imports (#220)
- Use explicit NIO modules `NIOCore`, `NIOPosix` and `NIOEmbedded` introduced with SwiftNIO 2.32.0
2021-08-19 09:42:23 +02:00
Fabian Fett a49a87341a Update swiftformat (#196)
changes: 
* Update swiftformat from 0.44 to 0.47
* Adjust rules
2021-03-26 10:34:34 -07:00
tomer doron 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 Fett 0008e59bab Rename payload to event (#115) 2020-06-07 07:47:05 -07:00
tomer doron 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 Fett 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
Fabian Fett 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
tomer doron 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
tomer doron 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 Fett 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