Commit Graph
14 Commits
Author SHA1 Message Date
chrislu 4e4e3ce1a8 tests: align ApiVersions test expectations with advertised ranges (ListOffsets v0-2, Fetch v0-7) 2025-09-12 17:43:57 -07:00
chrislu 7790155827 kafka gateway: strip client_id in header; align handlers with spec; fix ApiVersions count; correct Metadata/ListOffsets v0 tests; robust Produce v2+ parsing (transactional_id fallback, acks=0 empty response, unknown topic errors); relax record set/test extraction; fix OffsetCommit/OffsetFetch parsing and tests; Fetch returns UNKNOWN_TOPIC_OR_PARTITION for missing topic 2025-09-12 17:11:54 -07:00
chrislu 48a0b49880 protocol: align request parsing with Kafka specs; remove client_id skips; revert OffsetFetch v0-v5 to classic encodings; adjust FindCoordinator parsing; update ApiVersions Metadata max v7; fix tests to pass apiVersion and expectations 2025-09-12 16:19:23 -07:00
chrislu 3802106acf mq(kafka): Phase 3 Step 3 - Consumer Coordination
- Implement Heartbeat API (key 12) for consumer group liveness
- Implement LeaveGroup API (key 13) for graceful consumer departure
- Add comprehensive consumer coordination with state management:
  * Heartbeat validation with generation and member checks
  * Rebalance state signaling to consumers via heartbeat responses
  * Graceful member departure with automatic rebalancing trigger
  * Leader election when group leader leaves
  * Group state transitions: stable -> rebalancing -> empty
  * Subscription topic updates when members leave
- Update ApiVersions to advertise 13 APIs total (was 11)
- Complete test suite with 12 new test cases covering:
  * Heartbeat success, rebalance signaling, generation validation
  * Member departure, leader changes, empty group handling
  * Error conditions (unknown member, wrong generation, invalid group)
  * End-to-end coordination workflows
  * Request parsing and response building
- All integration tests pass with updated API count (13 APIs)
- E2E tests show '96 bytes' response (increased from 84 bytes)

This completes Phase 3 consumer group implementation, providing full
distributed consumer coordination compatible with Kafka client libraries.
Consumers can now join groups, coordinate partitions, commit offsets,
send heartbeats, and leave gracefully with automatic rebalancing.
2025-09-10 13:50:30 -07:00
chrislu 26acff4373 mq(kafka): Phase 3 Step 2 - Offset Management
- Implement OffsetCommit API (key 8) for consumer offset persistence
- Implement OffsetFetch API (key 9) for consumer offset retrieval
- Add comprehensive offset management with group-level validation
- Integrate offset storage with existing consumer group coordinator
- Support offset retention, metadata, and leader epoch handling
- Add partition assignment validation for offset commits
- Update ApiVersions to advertise 11 APIs total (was 9)
- Complete test suite with 14 new test cases covering:
  * Basic offset commit/fetch operations
  * Error conditions (invalid group, wrong generation, unknown member)
  * End-to-end offset persistence workflows
  * Request parsing and response building
- All integration tests pass with updated API count (11 APIs)
- E2E tests show '84 bytes' response (increased from 72 bytes)

This completes consumer offset management, enabling Kafka clients to
reliably track and persist their consumption progress across sessions.
2025-09-10 13:39:20 -07:00
chrislu d415911943 mq(kafka): Phase 3 Step 1 - Consumer Group Foundation
- Implement comprehensive consumer group coordinator with state management
- Add JoinGroup API (key 11) for consumer group membership
- Add SyncGroup API (key 14) for partition assignment coordination
- Create Range and RoundRobin assignment strategies
- Support consumer group lifecycle: Empty -> PreparingRebalance -> CompletingRebalance -> Stable
- Add automatic member cleanup and expired session handling
- Comprehensive test coverage for consumer groups, assignment strategies
- Update ApiVersions to advertise 9 APIs total (was 7)
- All existing integration tests pass with new consumer group support

This provides the foundation for distributed Kafka consumers with automatic
partition rebalancing and group coordination, compatible with standard Kafka clients.
2025-09-10 13:34:28 -07:00
chrislu 59f1c3dda5 mq(kafka): implement Fetch handler with record batch construction, high watermark tracking, and comprehensive test coverage for consumer functionality 2025-09-10 12:57:19 -07:00
chrislu c7f163ee41 mq(kafka): implement Produce handler with record parsing, offset assignment, ledger integration; supports fire-and-forget and acknowledged modes with comprehensive test coverage 2025-09-10 12:53:45 -07:00
chrislu 3eaff0e787 mq(kafka): implement offset ledger system with thread-safe in-memory mapping from Kafka offsets to timestamps; integrate with ListOffsets handler and topic lifecycle 2025-09-10 12:46:29 -07:00
chrislu c7b6103e31 mq(kafka): implement CreateTopics/DeleteTopics handlers with in-memory topic registry and comprehensive validation; now supports 5 API keys 2025-09-10 12:42:03 -07:00
chrislu 9b6faa1910 mq(kafka): implement ListOffsets protocol handler stub for earliest/latest offset queries with comprehensive tests 2025-09-10 12:36:27 -07:00
chrislu e5920f55f3 mq(kafka): implement Metadata protocol handler stub with broker discovery and comprehensive tests 2025-09-10 12:32:33 -07:00
chrislu fdb7f94526 fmt 2025-09-10 12:30:11 -07:00
chrislu 7c4a5f546c mq(kafka): implement ApiVersions protocol handler with manual binary encoding and comprehensive unit tests 2025-09-10 11:21:52 -07:00