Skip to content
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

Cleanup: Logging and some more #447

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions Sources/PostgresNIO/New/Extensions/Logging+PSQL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ extension PSQLConnection {
case message = "psql_message"
case messageID = "psql_message_id"
case messagePayload = "psql_message_payload"

case rowCount = "psql_row_count"

case database = "psql_database"
case username = "psql_username"

Expand Down
2 changes: 1 addition & 1 deletion Sources/PostgresNIO/New/PSQLRowStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ final class PSQLRowStream: @unchecked Sendable {
precondition(!newRows.isEmpty, "Expected to get rows!")
self.eventLoop.preconditionInEventLoop()
self.logger.trace("Row stream received rows", metadata: [
"row_count": "\(newRows.count)"
.rowCount: "\(newRows.count)"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inconsistency with all other log statements.

])

switch self.downstreamState {
Expand Down
6 changes: 3 additions & 3 deletions Sources/PostgresNIO/New/PostgresChannelHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ final class PostgresChannelHandler: ChannelDuplexHandler {
}

func errorCaught(context: ChannelHandlerContext, error: Error) {
self.logger.debug("Channel error caught.", metadata: [.error: "\(error)"])
self.logger.debug("Channel error caught.", metadata: [.error: "\(String(reflecting: error))"])
let action = self.state.errorHappened(.connectionError(underlying: error))
self.run(action, with: context)
}
Expand Down Expand Up @@ -563,8 +563,8 @@ final class PostgresChannelHandler: ChannelDuplexHandler {
_ cleanup: ConnectionStateMachine.ConnectionAction.CleanUpContext,
context: ChannelHandlerContext
) {
self.logger.debug("Cleaning up and closing connection.", metadata: [.error: "\(cleanup.error)"])
self.logger.debug("Cleaning up and closing connection.", metadata: [.error: "\(String(reflecting: cleanup.error))"])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example of what it solves:

Screenshot 2024-01-01 at 9 20 09 PM


// 1. fail all tasks
cleanup.tasks.forEach { task in
task.failWithError(cleanup.error)
Expand Down
1 change: 0 additions & 1 deletion Sources/PostgresNIO/Utilities/PostgresJSONDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ extension PostgresJSONDecoder {
}
}

//@available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)
Copy link
Contributor Author

@MahdiBM MahdiBM Jan 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some Sendable warning for these 2 JSON-Coder conformances. I didn't try to solve them because someone (Fabian probably?) tried to solve them but apparently stopped at some point (judging by the comment).

extension JSONDecoder: PostgresJSONDecoder {}

private let jsonDecoderLocked: NIOLockedValueBox<PostgresJSONDecoder> = NIOLockedValueBox(JSONDecoder())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ final class ConnectionPoolTests: XCTestCase {

pool.connectionReceivedNewMaxStreamSetting(connection, newMaxStreamSetting: 21)

for (index, request) in requests.enumerated() {
for (_, request) in requests.enumerated() {
Copy link
Contributor Author

@MahdiBM MahdiBM Jan 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning for unused variable.

let connection = try await request.future.success
connections.append(connection)
}
Expand Down
Loading