Skip to content

API Refactoring #273

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 6 commits into from
Nov 9, 2022
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
3 changes: 0 additions & 3 deletions Examples/Benchmark/BenchmarkHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ import NIOCore

@main
struct BenchmarkHandler: EventLoopLambdaHandler {
typealias Event = String
typealias Output = String

static func makeHandler(context: LambdaInitializationContext) -> EventLoopFuture<Self> {
context.eventLoop.makeSucceededFuture(BenchmarkHandler())
}
Expand Down
2 changes: 1 addition & 1 deletion Examples/Benchmark/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.5
// swift-tools-version:5.7

import PackageDescription

Expand Down
2 changes: 1 addition & 1 deletion Examples/Deployment/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.5
// swift-tools-version:5.7

import PackageDescription

Expand Down
5 changes: 1 addition & 4 deletions Examples/Deployment/Sources/Benchmark/BenchmarkHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//

import AWSLambdaRuntimeCore
import NIO
import NIOCore

// If you would like to benchmark Swift's Lambda Runtime,
// use this example which is more performant.
Expand All @@ -22,9 +22,6 @@ import NIO

@main
struct BenchmarkHandler: EventLoopLambdaHandler {
typealias Event = String
typealias Output = String

static func makeHandler(context: LambdaInitializationContext) -> EventLoopFuture<Self> {
context.eventLoop.makeSucceededFuture(BenchmarkHandler())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,7 @@ import AWSLambdaRuntime

// introductory example, the obligatory "hello, world!"
@main
struct HelloWorldHandler: LambdaHandler {
typealias Event = String
typealias Output = String

init(context: LambdaInitializationContext) async throws {
// setup your resources that you want to reuse here.
}

struct HelloWorldHandler: SimpleLambdaHandler {
func handle(_ event: String, context: LambdaContext) async throws -> String {
"hello, world"
}
Expand Down
9 changes: 1 addition & 8 deletions Examples/Echo/Lambda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@ import AWSLambdaRuntime
// in this example we are receiving and responding with strings

@main
struct MyLambda: LambdaHandler {
typealias Event = String
typealias Output = String

init(context: LambdaInitializationContext) async throws {
// setup your resources that you want to reuse for every invocation here.
}

struct MyLambda: SimpleLambdaHandler {
func handle(_ input: String, context: LambdaContext) async throws -> String {
// as an example, respond with the input's reversed
String(input.reversed())
Expand Down
2 changes: 1 addition & 1 deletion Examples/Echo/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.5
// swift-tools-version:5.7

import PackageDescription

Expand Down
7 changes: 1 addition & 6 deletions Examples/ErrorHandling/Lambda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ import AWSLambdaRuntime
// MARK: - Run Lambda

@main
struct MyLambda: LambdaHandler {
typealias Event = Request
typealias Output = Response

init(context: LambdaInitializationContext) async throws {}

struct MyLambda: SimpleLambdaHandler {
func handle(_ request: Request, context: LambdaContext) async throws -> Response {
// switch over the error type "requested" by the request, and trigger such error accordingly
switch request.error {
Expand Down
2 changes: 1 addition & 1 deletion Examples/ErrorHandling/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.5
// swift-tools-version:5.7

import PackageDescription

Expand Down
3 changes: 0 additions & 3 deletions Examples/Foundation/Lambda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ import Logging

@main
struct MyLambda: LambdaHandler {
typealias Event = Request
typealias Output = [Exchange]

let calculator: ExchangeRatesCalculator

init(context: LambdaInitializationContext) async throws {
Expand Down
2 changes: 1 addition & 1 deletion Examples/Foundation/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.5
// swift-tools-version:5.7

import PackageDescription

Expand Down
9 changes: 1 addition & 8 deletions Examples/JSON/Lambda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,7 @@ struct Response: Codable {
// codables to model your request and response objects

@main
struct MyLambda: LambdaHandler {
typealias Event = Request
typealias Output = Response

init(context: LambdaInitializationContext) async throws {
// setup your resources that you want to reuse for every invocation here.
}

struct MyLambda: SimpleLambdaHandler {
func handle(_ event: Request, context: LambdaContext) async throws -> Response {
// as an example, respond with the input event's reversed body
Response(body: String(event.body.reversed()))
Expand Down
2 changes: 1 addition & 1 deletion Examples/JSON/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.5
// swift-tools-version:5.7

import PackageDescription

Expand Down
9 changes: 1 addition & 8 deletions Examples/LocalDebugging/MyLambda/Lambda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,7 @@ import Shared
// a local server simulator which will allow local debugging

@main
struct MyLambda: LambdaHandler {
typealias Event = Request
typealias Output = Response

init(context: LambdaInitializationContext) async throws {
// setup your resources that you want to reuse for every invocation here.
}

struct MyLambda: SimpleLambdaHandler {
func handle(_ request: Request, context: LambdaContext) async throws -> Response {
// TODO: something useful
Response(message: "Hello, \(request.name)!")
Expand Down
2 changes: 1 addition & 1 deletion Examples/LocalDebugging/MyLambda/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.5
// swift-tools-version:5.7

import PackageDescription

Expand Down
2 changes: 1 addition & 1 deletion Examples/Testing/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.5
// swift-tools-version:5.7

import PackageDescription

Expand Down
9 changes: 1 addition & 8 deletions Examples/Testing/Sources/Lambda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@ import AWSLambdaRuntime
// in this example we are receiving and responding with strings

@main
struct MyLambda: LambdaHandler {
typealias Event = String
typealias Output = String

init(context: LambdaInitializationContext) async throws {
// setup your resources that you want to reuse for every invocation here.
}

struct MyLambda: SimpleLambdaHandler {
func handle(_ event: String, context: LambdaContext) async throws -> String {
// as an example, respond with the event's reversed body
String(event.reversed())
Expand Down
4 changes: 2 additions & 2 deletions Examples/Testing/Tests/LambdaTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import AWSLambdaTesting
import XCTest

class LambdaTest: XCTestCase {
func testIt() throws {
func testIt() async throws {
let input = UUID().uuidString
let result = try Lambda.test(MyLambda.self, with: input)
let result = try await Lambda.test(MyLambda.self, with: input)
XCTAssertEqual(result, String(input.reversed()))
}
}
10 changes: 8 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
// swift-tools-version:5.6
// swift-tools-version:5.7

import PackageDescription

let package = Package(
name: "swift-aws-lambda-runtime",
platforms: [
.macOS(.v12),
.iOS(.v15),
.tvOS(.v15),
.watchOS(.v8),
],
products: [
// this library exports `AWSLambdaRuntimeCore` and adds Foundation convenience methods
.library(name: "AWSLambdaRuntime", targets: ["AWSLambdaRuntime"]),
Expand All @@ -15,7 +21,7 @@ let package = Package(
.library(name: "AWSLambdaTesting", targets: ["AWSLambdaTesting"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMajor(from: "2.33.0")),
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMajor(from: "2.43.1")),
.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")),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
Expand Down
55 changes: 0 additions & 55 deletions Package@swift-5.4.swift

This file was deleted.

55 changes: 0 additions & 55 deletions Package@swift-5.5.swift

This file was deleted.

Loading