Skip to content

TCP B1: Add TCP client and server packet type enums, plus reading/writing them. - #421

Open
alex-clickhouse wants to merge 1 commit into
tcp/epic-a-wire-primitivesfrom
tcp/epic-b1-packet-envelope
Open

TCP B1: Add TCP client and server packet type enums, plus reading/writing them.#421
alex-clickhouse wants to merge 1 commit into
tcp/epic-a-wire-primitivesfrom
tcp/epic-b1-packet-envelope

Conversation

@alex-clickhouse

Copy link
Copy Markdown
Collaborator

No description provided.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Triage

Category: featureRisk: low

Summary
This PR adds two internal enums — ClientPacketType and ServerPacketType — defining the VarUInt packet-type codes for the in-progress TCP client (ClickHouse.Driver.Tcp). It also adds thin typed wrappers on the existing binary reader/writer (ReadServerPacketTypeAsync, WriteClientPacketType) and five matching tests covering round-trips, multi-byte VarUInt edge cases, and the directional overlap of code values. The change is purely additive inside the ClickHouse.Driver.Tcp project; the main HTTP-based driver and its production modules (ADO/, Types/, Http/, Copy/, Utility/) are untouched.

What this impacts

  • ClickHouse.Driver.Tcp/Protocol/ — two new files, two one-liner method additions to reader/writer
  • ClickHouse.Driver.Tcp.Tests/ — five new test cases
  • No public API surface (internal enums), no connection string changes, no existing behaviour altered

Concerns

  • PR is in DRAFT state; no linked issue. For a named series ("TCP B1") this is expected, but a tracking issue or epic reference would help reviewers understand scope and sequencing.

Required reviewer action

  • AI review with no comments → eligible for auto-merge per repo policy (once promoted out of DRAFT).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds first-class representations of ClickHouse TCP native-protocol packet type codes and convenience read/write helpers, with unit tests validating the VarUInt envelope behavior.

Changes:

  • Introduces ClientPacketType and ServerPacketType enums for packet envelope type codes.
  • Adds WriteClientPacketType and ReadServerPacketTypeAsync helpers over existing VarUInt primitives.
  • Extends protocol reader/writer tests to cover round-trips, overlap semantics, and unknown multi-byte codes.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ClickHouse.Driver.Tcp/Protocol/ServerPacketType.cs Adds server→client packet type enum and docs (needs doc fixes + backing type adjustment).
ClickHouse.Driver.Tcp/Protocol/ClientPacketType.cs Adds client→server packet type enum and docs (needs doc fixes + backing type adjustment).
ClickHouse.Driver.Tcp/Protocol/ClickHouseBinaryWriter.cs Adds WriteClientPacketType helper that writes the VarUInt type code.
ClickHouse.Driver.Tcp/Protocol/ClickHouseBinaryReader.cs Adds ReadServerPacketTypeAsync helper that reads the VarUInt type code.
ClickHouse.Driver.Tcp.Tests/Protocol/ClickHouseBinaryReaderWriterTests.cs Adds tests for packet type encoding/decoding and envelope composition.

Comment thread ClickHouse.Driver.Tcp/Protocol/ClientPacketType.cs Outdated
Comment thread ClickHouse.Driver.Tcp/Protocol/ClientPacketType.cs Outdated
Comment thread ClickHouse.Driver.Tcp/Protocol/ServerPacketType.cs Outdated
Comment thread ClickHouse.Driver.Tcp/Protocol/ServerPacketType.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Comment on lines +4 to +6
/// Packet type codes the server sends to the client, encoded as the leading VarUInt of each packet.
/// Codes overlap numerically with <see cref="ClientPacketType"/> but carry different meanings per direction
/// (e.g. code 2 is server <see cref="Exception"/> but client <see cref="ClientPacketType.Data"/>).
Comment on lines +4 to +6
/// Packet type codes the client sends to the server, encoded as the leading VarUInt of each packet.
/// Codes overlap numerically with <see cref="ServerPacketType"/> but carry different meanings per direction
/// (e.g. code 2 is client <see cref="Data"/> but server <see cref="ServerPacketType.Exception"/>).
}

[Test]
public async Task PacketTypeCodes_OverlapAcrossDirections_CarryDifferentMeaning()
@alex-clickhouse alex-clickhouse changed the title Add TCP client and server packet type enums, plus reading/writing them. TCP B1: Add TCP client and server packet type enums, plus reading/writing them. Jul 8, 2026
@alex-clickhouse
alex-clickhouse force-pushed the tcp/epic-b1-packet-envelope branch from 00d60cb to 09281f5 Compare July 10, 2026 12:42
@alex-clickhouse
alex-clickhouse marked this pull request as ready for review July 15, 2026 08:26
@alex-clickhouse
alex-clickhouse requested a review from mzitnik as a code owner July 15, 2026 08:26

@kavirajk kavirajk left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM 👍 looks like all the message types are covered as specs on both clients and server :)

@alex-clickhouse
alex-clickhouse force-pushed the tcp/epic-b1-packet-envelope branch from 09281f5 to 02bf5c5 Compare July 28, 2026 18:59
@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@alex-clickhouse
alex-clickhouse force-pushed the tcp/epic-b1-packet-envelope branch from 02bf5c5 to 6ba85af Compare July 29, 2026 07:05
@alex-clickhouse
alex-clickhouse force-pushed the tcp/epic-b1-packet-envelope branch from 6ba85af to 04c8175 Compare July 29, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants