Skip to content

feat(go): add delete segments support#3191

Open
matanper wants to merge 6 commits intoapache:masterfrom
matanper:go-delete-segments-sdk
Open

feat(go): add delete segments support#3191
matanper wants to merge 6 commits intoapache:masterfrom
matanper:go-delete-segments-sdk

Conversation

@matanper
Copy link
Copy Markdown

Expose the delete segments command in the Go SDK so clients can manage partition segment cleanup over TCP.

Which issue does this PR close?

Closes #3190

Rationale

The Go SDK was missing support for the existing DeleteSegments TCP command, so Go clients could not trigger partition segment cleanup through the SDK.

What changed?

The Go SDK now exposes DeleteSegments(streamId, topicId, partitionId, segmentsCount), adds the TCP command code and binary payload serialization, and includes a serialization test for the command wire format.

Local Execution

  • Passed: go test ./... from foreign/go
  • Passed: live Go SDK smoke test against apache/iggy:0.8.0 on TCP, including login, stream/topic creation, message send, DeleteSegments, topic fetch, and cleanup
  • Pre-commit hooks not ran

AI Usage

  1. Cursor
  2. Entire implementation
  3. Ran against apache/iggy:0.8.0 and tested it live
  4. Yes

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.10%. Comparing base (611fca0) to head (0c1af7f).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #3191   +/-   ##
=========================================
  Coverage     74.10%   74.10%           
  Complexity      943      943           
=========================================
  Files          1159     1161    +2     
  Lines        102033   102048   +15     
  Branches      79083    79083           
=========================================
+ Hits          75607    75622   +15     
  Misses        23765    23765           
  Partials       2661     2661           
Components Coverage Δ
Rust Core 75.33% <ø> (ø)
Java SDK 60.14% <ø> (ø)
C# SDK 69.38% <ø> (ø)
Python SDK 81.43% <ø> (ø)
Node SDK 91.53% <ø> (ø)
Go SDK 39.61% <100.00%> (+0.18%) ⬆️
Files with missing lines Coverage Δ
foreign/go/client/tcp/tcp_segment_management.go 100.00% <100.00%> (ø)
foreign/go/internal/command/segment.go 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +31 to +35
func TestIggyTcpClient_DeleteSegments(t *testing.T) {
clientConn, serverConn := net.Pipe()
defer func() {
_ = clientConn.Close()
}()
Copy link
Copy Markdown
Contributor

@chengxilo chengxilo Apr 30, 2026

Choose a reason for hiding this comment

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

My concern is that this specific test doesn't quite align with our current patterns, as most tests requiring a server live in the /bdd directory.

Long-term, I think we should move this type of testing to /bdd and provide a common scenario for every SDK to implement.

I'm also curious to hear what others think about moving this to BDD. Maybe we can add extra steps in basic_messaging.feature?

Copy link
Copy Markdown
Author

@matanper matanper Apr 30, 2026

Choose a reason for hiding this comment

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

I removed the unit test and moved the behavioral coverage into /bdd, matching how the rest of the Go TCP suite exercises the SDK against a live server.

Comment thread foreign/go/internal/command/segment.go Outdated
}

func (d *DeleteSegments) MarshalBinary() ([]byte, error) {
bytes, _ := iggcon.MarshalIdentifiers(d.StreamId, d.TopicId)
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.

This error should not be ignored.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I did it since it's unreachable in tests, I'll return it

Copy link
Copy Markdown
Contributor

@chengxilo chengxilo left a comment

Choose a reason for hiding this comment

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

Overall, a solid PR! I left some comment, regarding the test, I'm curious about you and others' opinion.

Expose the delete segments command in the Go SDK so clients can manage partition segment cleanup over TCP.
Add focused coverage for the TCP delete segments wrapper and command code while simplifying payload serialization through the shared identifier helper.
Explicitly ignore pipe close errors in the delete segments TCP test so Go lint passes under CI.
Avoid an impossible identifier serialization branch in delete segments payload encoding so patch coverage reflects the exercised command behavior.
Cover delete segments through the Go TCP BDD suite so server-backed SDK behavior follows the existing test layout.
@matanper matanper force-pushed the go-delete-segments-sdk branch from f4169c7 to 301398c Compare April 30, 2026 08:58
@chengxilo
Copy link
Copy Markdown
Contributor

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

go-sdk: Expose delete segments command

2 participants