Skip to content

Commit 852391e

Browse files
committed
swift format
1 parent f2d94a2 commit 852391e

File tree

3 files changed

+27
-28
lines changed

3 files changed

+27
-28
lines changed

Sources/AWSLambdaRuntime/Lambda.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public enum Lambda {
4141
var logger = logger
4242
do {
4343
while !Task.isCancelled {
44-
44+
4545
logger.trace("Waiting for next invocation")
4646
let (invocation, writer) = try await runtimeClient.nextInvocation()
4747
logger[metadataKey: "aws-request-id"] = "\(invocation.metadata.requestID)"

Sources/AWSLambdaRuntime/LambdaRuntime.swift

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,29 +95,29 @@ public final class LambdaRuntime<Handler>: Sendable where Handler: StreamingLamb
9595
guard let port = Int(ipAndPort[1]) else { throw LambdaRuntimeError(code: .invalidPort) }
9696

9797
do {
98-
try await LambdaRuntimeClient.withRuntimeClient(
99-
configuration: .init(ip: ip, port: port),
100-
eventLoop: self.eventLoop,
101-
logger: self.logger
102-
) { runtimeClient in
103-
try await Lambda.runLoop(
104-
runtimeClient: runtimeClient,
105-
handler: handler,
98+
try await LambdaRuntimeClient.withRuntimeClient(
99+
configuration: .init(ip: ip, port: port),
100+
eventLoop: self.eventLoop,
106101
logger: self.logger
107-
)
108-
}
109-
} catch {
110-
// catch top level errors that have not been handled until now
111-
// this avoids the runtime to crash and generate a backtrace
112-
self.logger.error("LambdaRuntime.run() failed with error", metadata: ["error": "\(error)"])
113-
if let error = error as? LambdaRuntimeError,
114-
error.code != .connectionToControlPlaneLost
115-
{
116-
// if the error is a LambdaRuntimeError but not a connection error,
117-
// we rethrow it to preserve existing behaviour
118-
throw error
102+
) { runtimeClient in
103+
try await Lambda.runLoop(
104+
runtimeClient: runtimeClient,
105+
handler: handler,
106+
logger: self.logger
107+
)
108+
}
109+
} catch {
110+
// catch top level errors that have not been handled until now
111+
// this avoids the runtime to crash and generate a backtrace
112+
self.logger.error("LambdaRuntime.run() failed with error", metadata: ["error": "\(error)"])
113+
if let error = error as? LambdaRuntimeError,
114+
error.code != .connectionToControlPlaneLost
115+
{
116+
// if the error is a LambdaRuntimeError but not a connection error,
117+
// we rethrow it to preserve existing behaviour
118+
throw error
119+
}
119120
}
120-
}
121121

122122
} else {
123123

Sources/AWSLambdaRuntime/LambdaRuntimeClient.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ final actor LambdaRuntimeClient: LambdaRuntimeClientProtocol {
7272
case lostConnection
7373
case connecting([ConnectionContinuation])
7474
case connected(Channel, LambdaChannelHandler<LambdaRuntimeClient>)
75-
75+
7676
static func == (lhs: ConnectionState, rhs: ConnectionState) -> Bool {
7777
switch (lhs, rhs) {
7878
case (.disconnected, .disconnected):
@@ -171,7 +171,7 @@ final actor LambdaRuntimeClient: LambdaRuntimeClientProtocol {
171171

172172
case .connected(let channel, _):
173173
channel.close(mode: .all, promise: nil)
174-
174+
175175
case .lostConnection:
176176
continuation.resume()
177177
}
@@ -191,7 +191,7 @@ final actor LambdaRuntimeClient: LambdaRuntimeClientProtocol {
191191
self.lambdaState = .waitingForNextInvocation
192192
let handler = try await self.makeOrGetConnection()
193193
let invocation = try await handler.nextInvocation()
194-
194+
195195
guard case .waitingForNextInvocation = self.lambdaState else {
196196
fatalError("Invalid state: \(self.lambdaState)")
197197
}
@@ -320,7 +320,6 @@ final actor LambdaRuntimeClient: LambdaRuntimeClientProtocol {
320320
case (.connected, .notClosing):
321321
self.connectionState = .disconnected
322322

323-
324323
case (.connected, .closing(let continuation)):
325324
self.connectionState = .disconnected
326325

@@ -394,8 +393,8 @@ final actor LambdaRuntimeClient: LambdaRuntimeClientProtocol {
394393
self.assumeIsolated { runtimeClient in
395394

396395
// resume any pending continuation on the handler
397-
if case .connected(_ , let handler) = runtimeClient.connectionState {
398-
if case .connected(_ , let lambdaState) = handler.state {
396+
if case .connected(_, let handler) = runtimeClient.connectionState {
397+
if case .connected(_, let lambdaState) = handler.state {
399398
if case .waitingForNextInvocation(let continuation) = lambdaState {
400399
continuation.resume(throwing: LambdaRuntimeError(code: .connectionToControlPlaneLost))
401400
}

0 commit comments

Comments
 (0)