kafka pubsub bindings add controlled startup seek metadata#4251
kafka pubsub bindings add controlled startup seek metadata#4251
Conversation
866c958 to
0e57eb4
Compare
There was a problem hiding this comment.
Pull request overview
Adds an opt-in “startup seek” capability to Kafka consumers used by pubsub.kafka and bindings.kafka, allowing controlled consumption start positions (earliest/latest/fixed offset/timestamp) without changing default behavior when unset.
Changes:
- Added new component metadata keys (
seekOnStart,seekValue,seekApplyWhen,seekOnce,seekPartition) for pubsub and bindings. - Implemented startup seek parsing + consumer-group Setup-time offset resets, including committed-offset and timestamp-based offset lookup helpers.
- Added unit tests covering metadata parsing and consumer Setup behavior for startup seek.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pubsub/kafka/metadata.yaml | Documents new startup-seek metadata for the Kafka pubsub component. |
| bindings/kafka/metadata.yaml | Documents new startup-seek metadata for the Kafka binding (input). |
| common/component/kafka/metadata.go | Adds new metadata fields + wires parsing into existing Kafka metadata decode flow. |
| common/component/kafka/startup_seek.go | Introduces startup-seek config parsing and helper methods for committed-offset/timestamp offset lookup. |
| common/component/kafka/consumer.go | Hooks startup seek into consumer group Setup to reset offsets on partition claims. |
| common/component/kafka/kafka.go | Stores startup seek config in the Kafka component and closes the seek client on shutdown. |
| common/component/kafka/metadata_test.go | Adds tests validating startup seek metadata parsing/validation. |
| common/component/kafka/consumer_test.go | Adds tests validating startup seek behavior in consumer Setup (earliest/offset/timestamp/partition). |
| docs/kafka-startup-seek-docs-pr.md | Adds a PR-scoped doc describing the feature, metadata, and examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
…fset/timestamp) Signed-off-by: SAHLI Hamza <hamza.sahli@mail.com>
…ekPartition Signed-off-by: SAHLI Hamza <hamza.sahli@mail.com>
Signed-off-by: SAHLI Hamza <hamza.sahli@mail.com>
Signed-off-by: SAHLI Hamza <hamza.sahli@mail.com>
0ebbe87 to
4f55111
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: SAHLI Hamza <hamza.sahli@mail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: SAHLI Hamza <hamza.sahli@mail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: SAHLI Hamza <hamza.sahli@mail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: SAHLI Hamza <hamza.sahli@mail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: SAHLI Hamza <hamza.sahli@mail.com>
docs(kafka): Controlled startup seek for Kafka pub/sub and binding
Summary
This change adds an opt-in startup seek capability for Kafka consumers used by
pubsub.kafkaandbindings.kafka.The feature allows a component to start consuming from:
earliestretained offsetlatestoffsettimestampDefault behavior is unchanged when the new metadata is not set.
New metadata
seekOnStartnevernever,earliest,latest,offset,timestampseekValueoffset/timestampseekOnStartseekApplyWhenifNoCheckpointalwaysor onlyifNoCheckpoint(no committed offset)seekOncetrueseekPartitionValidation rules
seekOnStart=earliest|latest:seekValueis ignored.seekOnStart=offset:seekValuemust be an integer offset>=0.seekOnStart=timestamp:seekValuemust be Unix milliseconds.seekApplyWhen=ifNoCheckpoint: seek only when no committed offset exists for the partition.seekApplyWhen=always: seek on every startup; withseekOnce=true, apply once then skip subsequent sessions.Examples
Example A — Start from earliest once when there’s no checkpoint
Example B — Force restart from a fixed offset (single partition)
Example C — Start from timestamp (Unix millis) across all partitions
Compatibility and migration notes
pubsub.kafka:consumerIDstill maps to Kafka consumer group (default app-id from runtime).bindings.kafka:initialOffsetbehavior remains unchanged when startup seek metadata is not used.seekOnStart != never, startup seek takes precedence over first-startinitialOffsetbehavior.earliestmeans earliest retained offset, not necessarily0.consumerGroupconfigured in bindings when checkpointing behavior is required.Operational notes
MarkMessage) are unchanged to preserve at-least-once behavior.seekPartitionis not assigned in the session, component logs a warning and continues.seekApplyWhen=alwaysandseekOnce=false, consumers intentionally re-read on every restart.Validation evidence (for PR)
Unit tests (repo)
go test ./common/component/kafka✅go test ./pubsub/kafka ./bindings/kafka✅End-to-end validation (non-PR harness)
daprdimage built with this branch’scomponents-contribchangesseekOnStart(earliest,latest,offset,timestamp)seekApplyWhen(ifNoCheckpoint,always)seekOnce(true,false)seekPartition(omitted/all vs0)seekOnStart=neverpassed=33, failed=0✅