Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 5 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,23 @@ let package = Package(
.library(name: "AWSLambdaTesting", targets: ["AWSLambdaTesting"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMajor(from: "2.30.0")),
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMajor(from: "2.32.0")),
.package(url: "https://github.com/apple/swift-log.git", .upToNextMajor(from: "1.4.2")),
.package(url: "https://github.com/swift-server/swift-backtrace.git", .upToNextMajor(from: "1.2.3")),
],
targets: [
.target(name: "AWSLambdaRuntime", dependencies: [
.byName(name: "AWSLambdaRuntimeCore"),
.product(name: "NIO", package: "swift-nio"),
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "NIOFoundationCompat", package: "swift-nio"),
]),
.target(name: "AWSLambdaRuntimeCore", dependencies: [
.product(name: "Logging", package: "swift-log"),
.product(name: "Backtrace", package: "swift-backtrace"),
.product(name: "NIOHTTP1", package: "swift-nio"),
.product(name: "NIO", package: "swift-nio"),
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "NIOConcurrencyHelpers", package: "swift-nio"),
.product(name: "NIOPosix", package: "swift-nio"),
.product(name: "_NIOConcurrency", package: "swift-nio"),
]),
.testTarget(name: "AWSLambdaRuntimeCoreTests", dependencies: [
Expand Down
2 changes: 1 addition & 1 deletion Sources/AWSLambdaRuntime/Lambda+Codable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import struct Foundation.Data
import class Foundation.JSONDecoder
import class Foundation.JSONEncoder
import NIO
import NIOCore
import NIOFoundationCompat

/// Extension to the `Lambda` companion to enable execution of Lambdas that take and return `Codable` events.
Expand Down
3 changes: 2 additions & 1 deletion Sources/AWSLambdaRuntimeCore/HTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
//
//===----------------------------------------------------------------------===//

import NIO
import NIOConcurrencyHelpers
import NIOCore
import NIOHTTP1
import NIOPosix

/// A barebone HTTP client to interact with AWS Runtime Engine which is an HTTP server.
/// Note that Lambda Runtime API dictate that only one requests runs at a time.
Expand Down
3 changes: 2 additions & 1 deletion Sources/AWSLambdaRuntimeCore/Lambda+LocalServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
#if DEBUG
import Dispatch
import Logging
import NIO
import NIOConcurrencyHelpers
import NIOCore
import NIOHTTP1
import NIOPosix

// This functionality is designed for local testing hence beind a #if DEBUG flag.
// For example:
Expand Down
2 changes: 1 addition & 1 deletion Sources/AWSLambdaRuntimeCore/Lambda+String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import NIO
import NIOCore

/// Extension to the `Lambda` companion to enable execution of Lambdas that take and return `String` events.
extension Lambda {
Expand Down
3 changes: 2 additions & 1 deletion Sources/AWSLambdaRuntimeCore/Lambda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import Darwin.C
import _NIOConcurrency
import Backtrace
import Logging
import NIO
import NIOCore
import NIOPosix

public enum Lambda {
public typealias Handler = ByteBufferLambdaHandler
Expand Down
2 changes: 1 addition & 1 deletion Sources/AWSLambdaRuntimeCore/LambdaConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import Dispatch
import Logging
import NIO
import NIOCore

extension Lambda {
internal struct Configuration: CustomStringConvertible {
Expand Down
2 changes: 1 addition & 1 deletion Sources/AWSLambdaRuntimeCore/LambdaContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import Dispatch
import Logging
import NIO
import NIOCore

// MARK: - InitializationContext

Expand Down
6 changes: 3 additions & 3 deletions Sources/AWSLambdaRuntimeCore/LambdaHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import _NIOConcurrency
import Dispatch
import NIO
import NIOCore

// MARK: - LambdaHandler

Expand Down Expand Up @@ -115,7 +115,7 @@ public protocol AsyncLambdaHandler: EventLoopLambdaHandler {
extension AsyncLambdaHandler {
public func handle(context: Lambda.Context, event: In) -> EventLoopFuture<Out> {
let promise = context.eventLoop.makePromise(of: Out.self)
promise.completeWithAsync {
promise.completeWithTask {
try await self.handle(event: event, context: context)
}
return promise.futureResult
Expand All @@ -127,7 +127,7 @@ extension AsyncLambdaHandler {
public static func main() {
Lambda.run { context -> EventLoopFuture<ByteBufferLambdaHandler> in
let promise = context.eventLoop.makePromise(of: ByteBufferLambdaHandler.self)
promise.completeWithAsync {
promise.completeWithTask {
try await Self(context: context)
}
return promise.futureResult
Expand Down
2 changes: 1 addition & 1 deletion Sources/AWSLambdaRuntimeCore/LambdaLifecycle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
//===----------------------------------------------------------------------===//

import Logging
import NIO
import NIOConcurrencyHelpers
import NIOCore

extension Lambda {
/// `Lifecycle` manages the Lambda process lifecycle.
Expand Down
2 changes: 1 addition & 1 deletion Sources/AWSLambdaRuntimeCore/LambdaRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import Dispatch
import Logging
import NIO
import NIOCore

extension Lambda {
/// LambdaRunner manages the Lambda runtime workflow, or business logic.
Expand Down
2 changes: 1 addition & 1 deletion Sources/AWSLambdaRuntimeCore/LambdaRuntimeClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//

import Logging
import NIO
import NIOCore
import NIOHTTP1

/// An HTTP based client for AWS Runtime Engine. This encapsulates the RESTful methods exposed by the Runtime Engine:
Expand Down
2 changes: 1 addition & 1 deletion Sources/AWSLambdaRuntimeCore/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//

import Dispatch
import NIO
import NIOPosix

internal enum Consts {
static let apiPrefix = "/2018-06-01"
Expand Down
3 changes: 2 additions & 1 deletion Sources/AWSLambdaTesting/Lambda+Testing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
@testable import AWSLambdaRuntimeCore
import Dispatch
import Logging
import NIO
import NIOCore
import NIOPosix

extension Lambda {
public struct TestConfig {
Expand Down
2 changes: 1 addition & 1 deletion Sources/CodableSample/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//

import AWSLambdaRuntime
import NIO
import NIOCore

struct Request: Codable {
let body: String
Expand Down
3 changes: 2 additions & 1 deletion Sources/MockServer/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
//===----------------------------------------------------------------------===//

import Foundation
import NIO
import NIOCore
import NIOHTTP1
import NIOPosix

internal struct MockServer {
private let group: EventLoopGroup
Expand Down
2 changes: 1 addition & 1 deletion Sources/StringSample/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//

import AWSLambdaRuntimeCore
import NIO
import NIOCore

// in this example we are receiving and responding with strings
struct Handler: EventLoopLambdaHandler {
Expand Down
2 changes: 1 addition & 1 deletion Tests/AWSLambdaRuntimeCoreTests/LambdaHandlerTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//

@testable import AWSLambdaRuntimeCore
import NIO
import NIOCore
import XCTest

class LambdaHandlerTest: XCTestCase {
Expand Down
3 changes: 2 additions & 1 deletion Tests/AWSLambdaRuntimeCoreTests/LambdaLifecycleTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

@testable import AWSLambdaRuntimeCore
import Logging
import NIO
import NIOCore
import NIOHTTP1
import NIOPosix
import XCTest

class LambdaLifecycleTest: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@

@testable import AWSLambdaRuntimeCore
import Logging
import NIO
import NIOCore
import NIOFoundationCompat
import NIOHTTP1
import NIOPosix
import NIOTestUtils
import XCTest

Expand Down
3 changes: 2 additions & 1 deletion Tests/AWSLambdaRuntimeCoreTests/LambdaTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

@testable import AWSLambdaRuntimeCore
import Logging
import NIO
import NIOCore
import NIOPosix
import XCTest

class LambdaTest: XCTestCase {
Expand Down
3 changes: 2 additions & 1 deletion Tests/AWSLambdaRuntimeCoreTests/MockLambdaServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
@testable import AWSLambdaRuntimeCore
import Foundation // for JSON
import Logging
import NIO
import NIOCore
import NIOHTTP1
import NIOPosix

internal final class MockLambdaServer {
private let logger = Logger(label: "MockLambdaServer")
Expand Down
3 changes: 2 additions & 1 deletion Tests/AWSLambdaRuntimeCoreTests/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

@testable import AWSLambdaRuntimeCore
import Logging
import NIO
import NIOCore
import NIOPosix
import XCTest

func runLambda(behavior: LambdaServerBehavior, handler: Lambda.Handler) throws {
Expand Down
3 changes: 2 additions & 1 deletion Tests/AWSLambdaRuntimeTests/Lambda+CodeableTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
@testable import AWSLambdaRuntime
@testable import AWSLambdaRuntimeCore
import Logging
import NIO
import NIOCore
import NIOFoundationCompat
import NIOPosix
import XCTest

class CodableLambdaTest: 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 @@ -14,7 +14,7 @@

import AWSLambdaRuntime
import AWSLambdaTesting
import NIO
import NIOCore
import XCTest

class LambdaTestingTests: XCTestCase {
Expand Down