Commit 3563675
v2.5.9: add CosmoSQLClient.CosmoKvPipes driver (binary protocol over UDS)
Mirror image of cosmokvd v0.4.0's PipesListener. Implements
ISqlDatabase via length-prefixed binary frames on a Unix Domain
Socket — no HTTP, no JSON, no Kestrel framing.
Connection string: Endpoint=pipes:///path/to/sock;AuthToken=<token>
Scope:
- AUTH handshake on Open (bearer token, FixedTimeEquals on server)
- QUERY (returns IReadOnlyList<SqlRow>)
- ExecuteAsync (returns int rows-affected)
- QueryStreamAsync (buffer-and-yield — cosmokvd's binary protocol
returns the full result set in one frame today)
- QueryTableAsync, QueryJsonStreamAsync (built on top of QueryAsync)
- BeginTransactionAsync / Commit / Rollback throw NotSupportedException;
callers needing explicit transactions stay on CosmoSQLClient.CosmoKvHttp
Framing matches the server's FrameCodec byte-for-byte: u8 opcode +
u32-LE body_len + body. SqlValue payloads use the same InvariantCulture
decimal-text encoding the JSON wire uses, so the only difference vs
HTTP is the envelope.
Concurrency: one in-process SemaphoreSlim(1,1) serialises Query/Execute
on the connection's single socket. Open multiple connections for
parallelism — same model as MsSql / Sqlite / Postgres drivers.
Pipe-lifecycle constraint borrowed from the server-side codec: body
arrays are owned (ToArray'd) BEFORE PipeReader.AdvanceTo, otherwise
the pipe can reclaim the underlying memory and any later access throws
ArgumentOutOfRangeException.
6 xUnit end-to-end tests against a real CosmoKvD instance:
- Open + dispose
- Bad token → SqlException.Auth
- Full CREATE/INSERT/SELECT round-trip (text + int + null params)
- Null parameter encode/decode
- 50 sequential statements on one connection
- BeginTransactionAsync throws NotSupported
Honesty about perf: same UDS + concurrent-reads lesson applies —
binary protocol wins only become measurable after the upstream
CosmoKvConnection._lock is broken. Infrastructure here for that
future + immediately useful for low-saturation latency-sensitive
workloads.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 826cdc4 commit 3563675
9 files changed
Lines changed: 887 additions & 1 deletion
File tree
- src/CosmoSQLClient.CosmoKvPipes
- tests/CosmoSQLClient.CosmoKvPipes.Tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
46 | 52 | | |
47 | 53 | | |
48 | 54 | | |
| |||
269 | 275 | | |
270 | 276 | | |
271 | 277 | | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
272 | 314 | | |
273 | 315 | | |
274 | 316 | | |
| |||
292 | 334 | | |
293 | 335 | | |
294 | 336 | | |
| 337 | + | |
| 338 | + | |
295 | 339 | | |
296 | 340 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
Lines changed: 74 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
0 commit comments