Merged
Conversation
This adds stick-table writing to the library.
There was a problem hiding this comment.
Pull request overview
Adds stick-table write/push support to the peers library so handlers can send stick-table definitions and entry updates back to HAProxy over the existing peer connection, with accompanying unit + e2e coverage and a usage example.
Changes:
- Introduce
peers.Writerand expose it viaWriterFromContext(ctx)for pushing stick-table updates. - Fix stick-table entry marshaling to encode map data correctly when sending updates.
- Add unit tests, e2e tests, and a runnable example demonstrating pushing entries (including timed/expiry and bulk).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| peers/writer.go | New writer implementation to send stick-table protocol messages. |
| peers/peers.go | Injects Writer into handler context via a new context key. |
| peers/sticktable/sticktables.go | Fixes entry marshaling to call MapData.Marshal (write path). |
| peers/protocol.go | Accepts update-ack messages silently (needed when pushing to HAProxy). |
| peers/writer_test.go | Adds writer-focused tests plus a round-trip decode test. |
| peers/e2e_test.go | Adds e2e coverage for pushing entries, timed expiry, and bulk updates. |
| peers/example/push/main.go | New example showing how to push stick-table entries from a handler. |
| peers/example/push/go.mod | Example module wiring (replace to local repo). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Handle short writes in Writer.writeMessage with a write loop - Share write mutex between Writer and protocolClient to prevent interleaved frames - Fix SendEntry to not mutate caller's EntryUpdate and protect ID assignment - Use bufio.Reader in helperDialPeer for reliable TCP status line reading - Fix push example to use IPv4AddressKey instead of StringKey for IP tables
- Wrap the connection in a 64KB bufio.Writer to reduce syscalls - Reuse a scratch buffer on the Writer instead of allocating per message - Add Flush() method for explicit flush control - Add SendEntries() for batch writes with a single lock and flush - SendEntry() auto-flushes for backward compat - Update protocolGilantClient to share the buffered writer
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds stick-table write support to the library.
I've added a few e2e tests as well:
Performance: