Skip to content

Commit bd39461

Browse files
committed
flatten examples
1 parent e861641 commit bd39461

39 files changed

+145
-110
lines changed

Examples/Simple/String/Package.swift renamed to Examples/Benchmark/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let package = Package(
1414
// this is the dependency on the swift-aws-lambda-runtime library
1515
// in real-world projects this would say
1616
// .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0")
17-
.package(name: "swift-aws-lambda-runtime", path: "../../.."),
17+
.package(name: "swift-aws-lambda-runtime", path: "../.."),
1818
],
1919
targets: [
2020
.executableTarget(

Examples/Benchmark/main.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the SwiftAWSLambdaRuntime open source project
4+
//
5+
// Copyright (c) 2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
import AWSLambdaRuntimeCore
16+
import NIOCore
17+
18+
// If you would like to benchmark Swift's Lambda Runtime,
19+
// use this example which is more performant.
20+
// `EventLoopLambdaHandler` does not offload the Lambda processing to a separate thread
21+
// while the closure-based handlers do.
22+
23+
struct MyLambda: EventLoopLambdaHandler {
24+
typealias Event = String
25+
typealias Output = String
26+
27+
func handle(_ event: String, context: Lambda.Context) -> EventLoopFuture<String> {
28+
context.eventLoop.makeSucceededFuture("hello, world!")
29+
}
30+
}
31+
32+
Lambda.run { $0.eventLoop.makeSucceededFuture(MyLambda()) }

Examples/Deployment/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM swift:5.5-amazonlinux2
2+
3+
RUN yum -y install zip

Examples/LambdaFunctions/Package.swift renamed to Examples/Deployment/Package.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ let package = Package(
1313
// good for benchmarking
1414
.executable(name: "Benchmark", targets: ["Benchmark"]),
1515
// demonstrate different types of error handling
16-
.executable(name: "ErrorHandling", targets: ["ErrorHandling"]),
17-
// fully featured example with domain specific business logic
18-
.executable(name: "CurrencyExchange", targets: ["CurrencyExchange"]),
1916
],
2017
dependencies: [
2118
// this is the dependency on the swift-aws-lambda-runtime library
@@ -30,11 +27,5 @@ let package = Package(
3027
.executableTarget(name: "HelloWorld", dependencies: [
3128
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
3229
]),
33-
.executableTarget(name: "ErrorHandling", dependencies: [
34-
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
35-
]),
36-
.executableTarget(name: "CurrencyExchange", dependencies: [
37-
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
38-
]),
3930
]
4031
)

Examples/LambdaFunctions/README.md renamed to Examples/Deployment/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# Lambda Functions Examples
1+
# Deployment Examples
22

33
This sample project is a collection of Lambda functions that demonstrates
44
how to write a simple Lambda function in Swift, and how to package and deploy it
55
to the AWS Lambda platform.
66

7-
The scripts are prepared to work from the `LambdaFunctions` folder.
7+
The scripts are prepared to work from the `Deployment` folder.
88

99
```
1010
git clone https://github.com/swift-server/swift-aws-lambda-runtime.git
11-
cd swift-aws-lambda-runtime/Examples/LambdaFunctions
11+
cd swift-aws-lambda-runtime/Examples/Deployment
1212
```
1313

1414
Note: The example scripts assume you have [jq](https://stedolan.github.io/jq/download/) command line tool installed.
@@ -27,7 +27,7 @@ Steps to deploy this sample to AWS Lambda using the AWS CLI:
2727
./scripts/deploy.sh
2828
```
2929

30-
Notes:
30+
Notes:
3131
- This script assumes you have AWS CLI installed and credentials setup in `~/.aws/credentials`.
3232
- The default lambda function name is `SwiftSample`. You can specify a different one updating `lambda_name` in `deploy.sh`
3333
- Update `s3_bucket=swift-lambda-test` in `deploy.sh` before running (AWS S3 buckets require a unique global name)
@@ -129,7 +129,7 @@ The `serverless-deploy.sh` script passes through any parameters to the Serverles
129129

130130
For the APIGateway sample:
131131

132-
The Serverless template will provide an endpoint which you can use to test the Lambda.
132+
The Serverless template will provide an endpoint which you can use to test the Lambda.
133133

134134
Outuput example:
135135

@@ -174,4 +174,4 @@ For all other samples use the AWS Lambda console.
174174
./scripts/serverless-remove.sh
175175
```
176176

177-
The script will ask you which sample Lambda you wish to remove from the previous depolyment.
177+
The script will ask you which sample Lambda you wish to remove from the previous deployment.

0 commit comments

Comments
 (0)