Skip to content

Adopt concurrency adoption guidelines #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Examples/Deployment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ The SAM template will provide an output labelled `LambdaApiGatewayEndpoint` whic

```
curl <<LambdaApiGatewayEndpoint>>
```
```

***Warning:*** This SAM template is only intended as a sample and creates a publicly accessible HTTP endpoint.

Expand Down Expand Up @@ -162,7 +162,7 @@ For example:

```
curl https://r39lvhfng3.execute-api.us-east-1.amazonaws.com/api
```
```

***Warning:*** This Serverless template is only intended as a sample and creates a publicly accessible HTTP endpoint.

Expand Down
30 changes: 0 additions & 30 deletions Examples/Deployment/scripts/SAM/APIGateway-template.yml

This file was deleted.

28 changes: 0 additions & 28 deletions Examples/Deployment/scripts/serverless/APIGateway-template.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ provider:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource: "*"
Resource: "*"

functions:
benchmarkFunction:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ provider:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource: "*"
Resource: "*"

functions:
hello:
Expand Down
2 changes: 1 addition & 1 deletion Sources/AWSLambdaRuntimeCore/Lambda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public enum Lambda {
return String(cString: value)
}

#if swift(>=5.5)
#if compiler(>=5.5) && canImport(_Concurrency)
// for testing and internal use
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
internal static func run<Handler: LambdaHandler>(configuration: Configuration = .init(), handlerType: Handler.Type) -> Result<Int, Error> {
Expand Down
2 changes: 1 addition & 1 deletion Sources/AWSLambdaRuntimeCore/LambdaHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import NIOCore

// MARK: - LambdaHandler

#if compiler(>=5.5)
#if compiler(>=5.5) && canImport(_Concurrency)
/// Strongly typed, processing protocol for a Lambda that takes a user defined `Event` and returns a user defined `Output` async.
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
public protocol LambdaHandler: EventLoopLambdaHandler {
Expand Down
3 changes: 1 addition & 2 deletions Sources/AWSLambdaTesting/Lambda+Testing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@
// XCTAssertEqual(result, "echo" + input)
// }

#if swift(>=5.5)
#if compiler(>=5.5) && canImport(_Concurrency)
import AWSLambdaRuntime
import AWSLambdaRuntimeCore
import Dispatch
import Logging
import NIOCore
Expand Down
2 changes: 1 addition & 1 deletion Tests/AWSLambdaRuntimeCoreTests/LambdaHandlerTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import NIOCore
import XCTest

class LambdaHandlerTest: XCTestCase {
#if compiler(>=5.5)
#if compiler(>=5.5) && canImport(_Concurrency)

// MARK: - LambdaHandler

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class CodableLambdaTest: XCTestCase {
XCTAssertEqual(response?.requestId, request.requestId)
}

#if swift(>=5.5)
#if compiler(>=5.5) && canImport(_Concurrency)
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
func testCodableVoidHandler() {
struct Handler: LambdaHandler {
Expand Down Expand Up @@ -183,7 +183,7 @@ private struct Response: Codable, Equatable {
}
}

#if swift(>=5.5)
#if compiler(>=5.5) && canImport(_Concurrency)
// NOTE: workaround until we have async test support on linux
// https://github.com/apple/swift-corelibs-xctest/pull/326
extension XCTestCase {
Expand Down
2 changes: 1 addition & 1 deletion Tests/AWSLambdaTestingTests/Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//

#if swift(>=5.5)
#if compiler(>=5.5) && canImport(_Concurrency)
import AWSLambdaRuntime
import AWSLambdaTesting
import NIOCore
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ First, add a dependency on the event packages:

Beyond the small cognitive complexity of using the `EventLoopFuture` based APIs, note these APIs should be used with extra care. An `EventLoopLambdaHandler` will execute the user code on the same `EventLoop` (thread) as the library, making processing faster but requiring the user code to never call blocking APIs as it might prevent the underlying process from functioning.

## Deploying to AWS Lambda
## Deploying to AWS Lambda

To deploy Lambda functions to AWS Lambda, you need to compile the code for Amazon Linux which is the OS used on AWS Lambda microVMs, package it as a Zip file, and upload to AWS.

Expand All @@ -160,7 +160,7 @@ The library defines three protocols for the implementation of a Lambda Handler.

### ByteBufferLambdaHandler

An `EventLoopFuture` based processing protocol for a Lambda that takes a `ByteBuffer` and returns a `ByteBuffer?` asynchronously.
An `EventLoopFuture` based processing protocol for a Lambda that takes a `ByteBuffer` and returns a `ByteBuffer?` asynchronously.

`ByteBufferLambdaHandler` is the lowest level protocol designed to power the higher level `EventLoopLambdaHandler` and `LambdaHandler` based APIs. Users are not expected to use this protocol, though some performance sensitive applications that operate at the `ByteBuffer` level or have special serialization needs may choose to do so.

Expand Down