vapor / postgres-nio

🐘 Non-blocking, event-driven Swift client for PostgreSQL.
https://api.vapor.codes/postgresnio/documentation/postgresnio/
MIT License
317 stars 72 forks source link

PostgresFrontendMessage: refactor encoding #381

Closed fabianfett closed 1 year ago

fabianfett commented 1 year ago

Currently we use an explicit PostgresFrontendMessage when we encode those messages into the outgoing ByteBuffer. However this can be wasteful if we need to transform the data that we have to explicitly match the PostgresFrontendMessage type. We should instead have methods on the Encoder that match the message types. This patch achieves exactly this.

codecov-commenter commented 1 year ago

Codecov Report

Merging #381 (93ca9c9) into main (718d154) will decrease coverage by 0.57%. The diff coverage is 79.79%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #381 +/- ## ========================================== - Coverage 44.44% 43.88% -0.57% ========================================== Files 118 107 -11 Lines 8639 8596 -43 ========================================== - Hits 3840 3772 -68 - Misses 4799 4824 +25 ``` | [Files Changed](https://app.codecov.io/gh/vapor/postgres-nio/pull/381?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor) | Coverage Δ | | |---|---|---| | [...rces/PostgresNIO/New/PostgresFrontendMessage.swift](https://app.codecov.io/gh/vapor/postgres-nio/pull/381?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9Qb3N0Z3Jlc05JTy9OZXcvUG9zdGdyZXNGcm9udGVuZE1lc3NhZ2Uuc3dpZnQ=) | `44.94% <0.00%> (-39.01%)` | :arrow_down: | | [...urces/PostgresNIO/New/PostgresChannelHandler.swift](https://app.codecov.io/gh/vapor/postgres-nio/pull/381?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9Qb3N0Z3Jlc05JTy9OZXcvUG9zdGdyZXNDaGFubmVsSGFuZGxlci5zd2lmdA==) | `62.28% <27.27%> (+1.22%)` | :arrow_up: | | [Sources/PostgresNIO/New/Messages/Startup.swift](https://app.codecov.io/gh/vapor/postgres-nio/pull/381?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9Qb3N0Z3Jlc05JTy9OZXcvTWVzc2FnZXMvU3RhcnR1cC5zd2lmdA==) | `100.00% <100.00%> (ø)` | | | [...stgresNIO/New/PostgresFrontendMessageEncoder.swift](https://app.codecov.io/gh/vapor/postgres-nio/pull/381?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9Qb3N0Z3Jlc05JTy9OZXcvUG9zdGdyZXNGcm9udGVuZE1lc3NhZ2VFbmNvZGVyLnN3aWZ0) | `100.00% <100.00%> (ø)` | |