Skip to content

apply swift-format #380

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 9 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion Plugins/AWSLambdaPackager/PluginUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
//===----------------------------------------------------------------------===//

import Dispatch
import Foundation
import PackagePlugin
import Synchronization
import Foundation

@available(macOS 15.0, *)
struct Utils {
Expand Down
4 changes: 3 additions & 1 deletion Sources/AWSLambdaRuntimeCore/ControlPlaneRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ enum ControlPlaneResponse: Hashable {
case error(ErrorResponse)
}

package struct InvocationMetadata: Hashable {
package
struct InvocationMetadata: Hashable
{
package let requestID: String
package let deadlineInMillisSinceEpoch: Int64
package let invokedFunctionARN: String
Expand Down
12 changes: 7 additions & 5 deletions Sources/AWSLambdaRuntimeCore/Lambda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ import ucrt
#endif

public enum Lambda {
package static func runLoop<RuntimeClient: LambdaRuntimeClientProtocol, Handler>(
runtimeClient: RuntimeClient,
handler: Handler,
logger: Logger
) async throws where Handler: StreamingLambdaHandler {
package
static func runLoop<RuntimeClient: LambdaRuntimeClientProtocol, Handler>(
runtimeClient: RuntimeClient,
handler: Handler,
logger: Logger
) async throws where Handler: StreamingLambdaHandler
{
var handler = handler

while !Task.isCancelled {
Expand Down
16 changes: 9 additions & 7 deletions Sources/AWSLambdaRuntimeCore/LambdaContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,15 @@ public struct LambdaContext: CustomDebugStringConvertible, Sendable {
}

/// This interface is not part of the public API and must not be used by adopters. This API is not part of semver versioning.
package static func __forTestsOnly(
requestID: String,
traceID: String,
invokedFunctionARN: String,
timeout: DispatchTimeInterval,
logger: Logger
) -> LambdaContext {
package
static func __forTestsOnly(
requestID: String,
traceID: String,
invokedFunctionARN: String,
timeout: DispatchTimeInterval,
logger: Logger
) -> LambdaContext
{
LambdaContext(
requestID: requestID,
traceID: traceID,
Expand Down
4 changes: 2 additions & 2 deletions Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

import Foundation
import Logging
import NIOCore
import NIOConcurrencyHelpers
import NIOCore

// We need `@unchecked` Sendable here, as `NIOLockedValueBox` does not understand `sending` today.
// We don't want to use `NIOLockedValueBox` here anyway. We would love to use Mutex here, but this
// sadly crashes the compiler today.
public final class LambdaRuntime<Handler>: @unchecked Sendable where Handler: StreamingLambdaHandler {
// TODO: We want to change this to Mutex as soon as this doesn't crash the Swift compiler on Linux anymore
let handlerMutex: NIOLockedValueBox<Optional<Handler>>
let handlerMutex: NIOLockedValueBox<Handler?>
let logger: Logger
let eventLoop: EventLoop

Expand Down
3 changes: 2 additions & 1 deletion Sources/AWSLambdaRuntimeCore/LambdaRuntimeClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ private final class LambdaChannelHandler<Delegate: LambdaChannelHandlerDelegate>
}

func reportError(
isolation: isolated (any Actor)? = #isolation,
isolation: isolated (any Actor)? =
#isolation,
_ error: any Error,
requestID: String
) async throws {
Expand Down
12 changes: 9 additions & 3 deletions Sources/AWSLambdaRuntimeCore/LambdaRuntimeClientProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,26 @@

import NIOCore

package protocol LambdaRuntimeClientResponseStreamWriter: LambdaResponseStreamWriter {
package
protocol LambdaRuntimeClientResponseStreamWriter: LambdaResponseStreamWriter
{
func write(_ buffer: ByteBuffer) async throws
func finish() async throws
func writeAndFinish(_ buffer: ByteBuffer) async throws
func reportError(_ error: any Error) async throws
}

package protocol LambdaRuntimeClientProtocol {
package
protocol LambdaRuntimeClientProtocol
{
associatedtype Writer: LambdaRuntimeClientResponseStreamWriter

func nextInvocation() async throws -> (Invocation, Writer)
}

package struct Invocation {
package
struct Invocation
{
package var metadata: InvocationMetadata
package var event: ByteBuffer

Expand Down
4 changes: 3 additions & 1 deletion Sources/AWSLambdaRuntimeCore/LambdaRuntimeError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
//
//===----------------------------------------------------------------------===//

package struct LambdaRuntimeError: Error {
package
struct LambdaRuntimeError: Error
{
package enum Code {
case closingRuntimeClient

Expand Down
Loading