apache / apache/iggy

feat(go): add diagnostic event subscription to client

Open
#3,219 8 comments 1 reaction 0 assignees View on GitHub
go good first issue
Dominant language
Rust
Stars
4.9k
Forks
432
Avg merge
2d 10h
Merged PRs (30d)
173

Description

### Description

## Summary

The Go SDK currently has no way for callers to observe client-level lifecycle events (connection state changes, auth state changes). The Rust SDK exposes these via `Client::subscribe_events()` returning a stream of `DiagnosticEvent`. This issue ports that capability to the Go SDK.

## Motivation

The Go TCP client already has TODO stubs in place for event emission, indicating this was anticipated:
- `foreign/go/client/tcp/tcp_core.go:399` — `// TODO publish event`
- `foreign/go/client/tcp/tcp_core.go:461` — `// TODO event pushing logic`
- `foreign/go/client/tcp/tcp_core.go:475` — `// TODO push shutdown event.

This is groundwork for adding a high-level `IggyConsumer` abstraction to the Go SDK (planned as a follow-up). Diagnostic events let the consumer detect disconnects, re-join consumer groups eagerly on reconnect, and resume cleanly. Beyond the consumer use case, the events are also useful for application-level observability (logging connection drops, exposing health metrics, etc.).

## Scope

In scope:
1. Add a `DiagnosticEvent` type in `foreign/go/contracts/` mirroring the Rust enum (5 variants, with a `String()` method matching the `snake_case` form used in Rust).
2. Add `SubscribeEvents() <-chan DiagnosticEvent` to the `Client` interface in `foreign/go/contracts/client.go`.
3. Implement a small fan-out broadcaster in the TCP client so multiple subscribers can each receive every event independently.
4. Wire emission into the TCP client:
- `Connected` — on initial connect and on every successful auto-reconnect (existing reconnect loop at `foreign/go/client/tcp/tcp_core.go:86-100, 351-401`)
- `Disconnected` — at the existing TODO at `tcp_core.go:399`
- `Shutdown` — at the existing TODO at `tcp_core.go:475`
- `SignedIn` — after successful `LoginUser`
- `SignedOut` — after successful `LogoutUser`
5. Integration test that subscribes, exercises connect → disconnect → reconnect → login → logout → close, and asserts the full event sequence is delivered.

### Component

Go SDK

### Proposed solution

_No response_

### Alternatives considered

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reading foreign/go/contracts/client.go and the Rust Client::subscribe_events() API to compare the intended event shapes. Then inspect the reconnect and TODO locations in foreign/go/client/tcp/tcp_core.go, especially lines 86-100, 351-401, 399, 461, and 475. Done means subscribers independently receive the five events through connect, disconnect, reconnect, login, logout, and close, with an integration test covering the sequence.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, rust
Domain
api, networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.