Skip to content
This repository was archived by the owner on Jul 14, 2020. It is now read-only.

Commit 5b9b72b

Browse files
authoredJan 16, 2020
Renamed LambdaRuntime to Runtime (#26)
1 parent 65345c0 commit 5b9b72b

File tree

11 files changed

+29
-37
lines changed

11 files changed

+29
-37
lines changed
 

‎Package.swift

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ let package = Package(
4848
"LambdaEvents",
4949
"LambdaRuntime",
5050
"LambdaRuntimeTestUtils",
51+
"NIO",
5152
"NIOTestUtils",
5253
"Logging",
5354
])

‎README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ let handler = APIGateway.handler() { (request, ctx) in
3838
}
3939
}
4040

41-
let runtime = try LambdaRuntime.createRuntime(eventLoopGroup: group, handler: handler)
41+
let runtime = try Runtime.createRuntime(eventLoopGroup: group, handler: handler)
4242
defer { try! runtime.syncShutdown() }
4343
try runtime.start().wait()
4444
```
@@ -130,9 +130,9 @@ let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
130130
defer { try! group.syncShutdownGracefully() }
131131

132132
do {
133-
let runtime = try LambdaRuntime.createRuntime(
133+
let runtime = try Runtime.createRuntime(
134134
eventLoopGroup: group,
135-
handler: LambdaRuntime.codable(squareNumber))
135+
handler: Runtime.codable(squareNumber))
136136

137137
defer { try! runtime.syncShutdown() }
138138

‎Sources/LambdaRuntime/Runtime+Codable.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22
import NIO
33
import NIOFoundationCompat
44

5-
extension LambdaRuntime {
5+
extension Runtime {
66

77
/// wrapper to use for the register function that wraps the encoding and decoding
88
public static func codable<Event: Decodable, Result: Encodable>(

‎Sources/LambdaRuntime/Runtime.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public struct InvocationError: Codable {
88
let errorMessage: String
99
}
1010

11-
final public class LambdaRuntime {
11+
final public class Runtime {
1212

1313
public typealias Handler = (NIO.ByteBuffer, Context) -> EventLoopFuture<NIO.ByteBuffer?>
1414

@@ -29,14 +29,14 @@ final public class LambdaRuntime {
2929

3030
/// the runtime shall be initialised with an EventLoopGroup, that is used throughout the lambda
3131
public static func createRuntime(eventLoopGroup: EventLoopGroup, environment: Environment? = nil, handler: @escaping Handler)
32-
throws -> LambdaRuntime
32+
throws -> Runtime
3333
{
3434
let env = try environment ?? Environment()
3535

3636
let client = RuntimeAPIClient(
3737
eventLoopGroup: eventLoopGroup,
3838
lambdaRuntimeAPI: env.lambdaRuntimeAPI)
39-
let runtime = LambdaRuntime(
39+
let runtime = Runtime(
4040
eventLoopGroup: eventLoopGroup,
4141
client: client,
4242
environment: env,

‎Tests/LambdaRuntimeTests/Runtime+CodableTests.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class RuntimeCodableTests: XCTestCase {
2828
defer {
2929
XCTAssertNoThrow(try eventLoopGroup.syncShutdownGracefully())
3030
}
31-
let handler = LambdaRuntime.codable { (req: TestRequest, ctx) -> EventLoopFuture<TestResponse> in
31+
let handler = Runtime.codable { (req: TestRequest, ctx) -> EventLoopFuture<TestResponse> in
3232
return ctx.eventLoop.makeSucceededFuture(TestResponse(greeting: "Hello \(req.name)!"))
3333
}
3434

@@ -52,7 +52,7 @@ class RuntimeCodableTests: XCTestCase {
5252
defer {
5353
XCTAssertNoThrow(try eventLoopGroup.syncShutdownGracefully())
5454
}
55-
let handler = LambdaRuntime.codable { (req: TestRequest, ctx) -> EventLoopFuture<TestResponse> in
55+
let handler = Runtime.codable { (req: TestRequest, ctx) -> EventLoopFuture<TestResponse> in
5656
return ctx.eventLoop.makeSucceededFuture(TestResponse(greeting: "Hello \(req.name)!"))
5757
}
5858

@@ -81,7 +81,7 @@ class RuntimeCodableTests: XCTestCase {
8181
defer {
8282
XCTAssertNoThrow(try eventLoopGroup.syncShutdownGracefully())
8383
}
84-
let handler = LambdaRuntime.codable { (req: TestRequest, ctx) -> EventLoopFuture<Void> in
84+
let handler = Runtime.codable { (req: TestRequest, ctx) -> EventLoopFuture<Void> in
8585
return ctx.eventLoop.makeSucceededFuture(Void())
8686
}
8787

@@ -101,7 +101,7 @@ class RuntimeCodableTests: XCTestCase {
101101
defer {
102102
XCTAssertNoThrow(try eventLoopGroup.syncShutdownGracefully())
103103
}
104-
let handler = LambdaRuntime.codable { (req: TestRequest, ctx) -> EventLoopFuture<Void> in
104+
let handler = Runtime.codable { (req: TestRequest, ctx) -> EventLoopFuture<Void> in
105105
return ctx.eventLoop.makeSucceededFuture(Void())
106106
}
107107

@@ -127,7 +127,7 @@ class RuntimeCodableTests: XCTestCase {
127127
defer {
128128
XCTAssertNoThrow(try eventLoopGroup.syncShutdownGracefully())
129129
}
130-
let handler = LambdaRuntime.codable { (req: TestRequest, ctx) -> EventLoopFuture<Void> in
130+
let handler = Runtime.codable { (req: TestRequest, ctx) -> EventLoopFuture<Void> in
131131
return ctx.eventLoop.makeFailedFuture(RuntimeError.unknown)
132132
}
133133

‎Tests/LambdaRuntimeTests/RuntimeTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class RuntimeTests: XCTestCase {
1616
defer { XCTAssertNoThrow(try group.syncShutdownGracefully()) }
1717

1818
do {
19-
let runtime = try LambdaRuntime.createRuntime(eventLoopGroup: group) { (_, ctx) in
19+
let runtime = try Runtime.createRuntime(eventLoopGroup: group) { (_, ctx) in
2020
return ctx.eventLoop.makeSucceededFuture(nil)
2121
}
2222
defer { XCTAssertNoThrow(try runtime.syncShutdown()) }
@@ -34,7 +34,7 @@ class RuntimeTests: XCTestCase {
3434
defer { XCTAssertNoThrow(try group.syncShutdownGracefully()) }
3535

3636
do {
37-
let runtime = try LambdaRuntime.createRuntime(eventLoopGroup: group) { (_, ctx) in
37+
let runtime = try Runtime.createRuntime(eventLoopGroup: group) { (_, ctx) in
3838
return ctx.eventLoop.makeSucceededFuture(nil)
3939
}
4040
defer { XCTAssertNoThrow(try runtime.syncShutdown()) }

‎examples/EventSources/Sources/EventSources/main.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -106,28 +106,28 @@ func printOriginalPayload(_ handler: @escaping (NIO.ByteBuffer, Context) -> Even
106106
do {
107107
logger.info("start runtime")
108108
let environment = try Environment()
109-
let handler: LambdaRuntime.Handler
109+
let handler: Runtime.Handler
110110

111111
switch environment.handlerName {
112112
case "sns":
113-
handler = printOriginalPayload(LambdaRuntime.codable(handleSNS))
113+
handler = printOriginalPayload(Runtime.codable(handleSNS))
114114
case "sqs":
115-
handler = printOriginalPayload(LambdaRuntime.codable(handleSQS))
115+
handler = printOriginalPayload(Runtime.codable(handleSQS))
116116
case "dynamo":
117-
handler = printOriginalPayload(LambdaRuntime.codable(handleDynamoStream))
117+
handler = printOriginalPayload(Runtime.codable(handleDynamoStream))
118118
case "schedule":
119-
handler = printOriginalPayload(LambdaRuntime.codable(handleCloudwatchSchedule))
119+
handler = printOriginalPayload(Runtime.codable(handleCloudwatchSchedule))
120120
case "api":
121121
handler = printOriginalPayload(APIGateway.handler(handleAPIRequest))
122122
case "s3":
123-
handler = printOriginalPayload(LambdaRuntime.codable(handleS3))
123+
handler = printOriginalPayload(Runtime.codable(handleS3))
124124
case "loadbalancer":
125125
handler = printOriginalPayload(ALB.handler(multiValueHeadersEnabled: true, handleLoadBalancerRequest))
126126
default:
127127
handler = printPayload
128128
}
129129

130-
let runtime = try LambdaRuntime.createRuntime(eventLoopGroup: group, handler: handler)
130+
let runtime = try Runtime.createRuntime(eventLoopGroup: group, handler: handler)
131131
defer { try! runtime.syncShutdown() }
132132
logger.info("starting runloop")
133133

‎examples/SquareNumber/Sources/SquareNumber/main.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ defer {
2727

2828
do {
2929

30-
let handler: LambdaRuntime.Handler
30+
let handler: Runtime.Handler
3131
switch ProcessInfo.processInfo.environment["_HANDLER"] {
3232
case "printNumber":
33-
handler = LambdaRuntime.codable(printNumber)
33+
handler = Runtime.codable(printNumber)
3434
default:
35-
handler = LambdaRuntime.codable(squareNumber)
35+
handler = Runtime.codable(squareNumber)
3636
}
3737

38-
let runtime = try LambdaRuntime.createRuntime(eventLoopGroup: group, handler: handler)
38+
let runtime = try Runtime.createRuntime(eventLoopGroup: group, handler: handler)
3939
defer { try! runtime.syncShutdown() }
4040

4141
try runtime.start().wait()

‎examples/TodoAPIGateway/Package.resolved

-9
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,6 @@
9191
"version": "2.5.0"
9292
}
9393
},
94-
{
95-
"package": "swift-nio-ssl-support",
96-
"repositoryURL": "https://github.com/apple/swift-nio-ssl-support.git",
97-
"state": {
98-
"branch": null,
99-
"revision": "c02eec4e0e6d351cd092938cf44195a8e669f555",
100-
"version": "1.0.0"
101-
}
102-
},
10394
{
10495
"package": "swift-nio-transport-services",
10596
"repositoryURL": "https://github.com/apple/swift-nio-transport-services.git",

‎examples/TodoAPIGateway/Sources/TodoAPIGateway/main.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ do {
2727

2828
logger.info("register function")
2929

30-
let handler: LambdaRuntime.Handler
30+
let handler: Runtime.Handler
3131
switch env.handlerName {
3232
case "list":
3333
handler = APIGateway.handler(controller.listTodos)
@@ -47,7 +47,7 @@ do {
4747

4848
logger.info("starting runloop")
4949

50-
let runtime = try LambdaRuntime.createRuntime(eventLoopGroup: group, environment: env, handler: handler)
50+
let runtime = try Runtime.createRuntime(eventLoopGroup: group, environment: env, handler: handler)
5151
defer { try! runtime.syncShutdown() }
5252
try runtime.start().wait()
5353
}

‎examples/URLRequestWithSession/Sources/URLRequestWithSession/main.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
5050
defer { try! group.syncShutdownGracefully() }
5151

5252
do {
53-
let runtime = try LambdaRuntime.createRuntime(eventLoopGroup: group, handler: echoCall)
53+
let runtime = try Runtime.createRuntime(eventLoopGroup: group, handler: echoCall)
5454
defer { try! runtime.syncShutdown() }
5555

5656
try runtime.start().wait()

0 commit comments

Comments
 (0)
This repository has been archived.