-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d89a723
commit 8f9a39d
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,51 @@ | ||
import PostgresNIO | ||
import NIOCore | ||
import Logging | ||
import Backtrace | ||
|
||
@main | ||
enum Repro { | ||
static func main() async throws { | ||
Backtrace.install() | ||
|
||
var mlogger = Logger(label: "psql") | ||
mlogger.logLevel = .debug | ||
let logger = mlogger | ||
|
||
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1) | ||
defer { try? eventLoopGroup.syncShutdownGracefully() } | ||
|
||
do { | ||
let connection = try await PostgresConnection.connect( | ||
on: eventLoopGroup.next(), | ||
configuration: .init( | ||
host: "host.docker.internal", | ||
username: "test_username", | ||
password: "test_password", | ||
database: "test_database", | ||
tls: .disable | ||
), | ||
id: 1, | ||
logger: logger | ||
) | ||
|
||
for i in 0..<100 { | ||
let rows = try await connection.query("SELECT \(i)", logger: logger) | ||
for try await row in rows.decode(Int.self) { | ||
logger.info("Row received: \(row)") | ||
} | ||
} | ||
|
||
try await connection.closeGracefully() | ||
} catch { | ||
logger.error("Error caught", metadata: ["error": "\(String(reflecting: error))"]) | ||
exit(1) | ||
} | ||
|
||
logger.info("Bye") | ||
|
||
// try await ContinuousClock().sleep(until: .now + .seconds(120)) | ||
|
||
// try await client.shutdown(graceful: false) | ||
} | ||
} |