-
Notifications
You must be signed in to change notification settings - Fork 113
[core] Only one LambdaRuntime.run()
can be called at a time (fix #507)
#508
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
Open
sebsto
wants to merge
26
commits into
swift-server:main
Choose a base branch
from
sebsto:sebsto/fix_507
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
456569a
make LambdaRuntime a singleton without breaking the API
sebsto a63a639
fix license header
sebsto 40b6127
convert Mutex to NIOLockedValueBox
sebsto d474eba
Replace NIOLockedValueBox with Mutex
sebsto 46e76f3
revert replacing NIOLockedValueBox by Mutex
sebsto 299b9bc
remove typed throw (workaround for https://github.com/swiftlang/swift…
sebsto e3a3851
fix integration tests
sebsto 4ebf24f
Replace NIOLockedValueBox with Mutex
sebsto f3e65ac
Merge branch 'main' into sebsto/fix_507
sebsto 3aee427
use Atomic instead of Mutex.
sebsto e445f90
Merge branch 'sebsto/fix_507' of github.com:sebsto/swift-aws-lambda-r…
sebsto 0509eaa
revert `try` on `runtime.init()` in doc
sebsto aa6395f
revert unwanted change
sebsto 066ab76
revert unwanted change
sebsto e01b25d
swift-format
sebsto 23c4b64
Merge branch 'main' into sebsto/fix_507
sebsto 57e2396
Update Sources/AWSLambdaRuntime/LambdaRuntime.swift
sebsto 85c988d
Update Sources/AWSLambdaRuntime/LambdaRuntime.swift
sebsto ab80580
Update Sources/AWSLambdaRuntime/LambdaRuntimeError.swift
sebsto 10304ce
Update Sources/AWSLambdaRuntime/LambdaRuntimeError.swift
sebsto c1e68fc
Update Tests/AWSLambdaRuntimeTests/LambdaRuntimeTests.swift
sebsto 918492a
Update Tests/AWSLambdaRuntimeTests/LambdaRuntimeTests.swift
sebsto 6ada041
Update Tests/AWSLambdaRuntimeTests/LambdaRuntimeTests.swift
sebsto 06df831
add package visibility to Code
sebsto 50b9df8
swift format
sebsto fa0fd88
remove print statement
sebsto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the SwiftAWSLambdaRuntime open source project | ||
// | ||
// Copyright (c) 2025 Apple Inc. and the SwiftAWSLambdaRuntime project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import Foundation | ||
import Logging | ||
import NIOCore | ||
import Synchronization | ||
import Testing | ||
|
||
@testable import AWSLambdaRuntime | ||
|
||
@Suite("LambdaRuntimeTests") | ||
final class LambdaRuntimeTests { | ||
sebsto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@Test("LambdaRuntime can only be initialized once") | ||
func testLambdaRuntimeInitializationFatalError() throws { | ||
|
||
// First initialization should succeed | ||
try _ = LambdaRuntime(handler: MockHandler(), eventLoop: Lambda.defaultEventLoop, logger: Logger(label: "Test")) | ||
|
||
// Second initialization should trigger LambdaRuntimeError | ||
#expect(throws: LambdaRuntimeError.self) { | ||
try _ = LambdaRuntime( | ||
handler: MockHandler(), | ||
eventLoop: Lambda.defaultEventLoop, | ||
logger: Logger(label: "Test") | ||
) | ||
} | ||
|
||
} | ||
} | ||
|
||
struct MockHandler: StreamingLambdaHandler { | ||
mutating func handle( | ||
_ event: NIOCore.ByteBuffer, | ||
responseWriter: some AWSLambdaRuntime.LambdaResponseStreamWriter, | ||
context: AWSLambdaRuntime.LambdaContext | ||
) async throws { | ||
|
||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.