Skip to content

feat(go): add diagnostic event subscription to client #3219

@explise

Description

@explise

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions