Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set opencdc.collection metadata #129

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
remove kafka.topic
lovromazgon committed Apr 9, 2024
commit 436f675b2649698f73081a58c66431267ccad627
2 changes: 1 addition & 1 deletion acceptance_test.go
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ func (d AcceptanceTestDriver) ReadFromDestination(t *testing.T, records []sdk.Re

recs := make([]sdk.Record, len(kgoRecs))
for i, rec := range kgoRecs {
metadata := sdk.Metadata{MetadataKafkaTopic: rec.Topic}
metadata := sdk.Metadata{}
metadata.SetCollection(rec.Topic)
metadata.SetCreatedAt(rec.Timestamp)

4 changes: 1 addition & 3 deletions source.go
Original file line number Diff line number Diff line change
@@ -24,8 +24,6 @@ import (
)

const (
// MetadataKafkaTopic is the metadata key for storing the kafka topic
MetadataKafkaTopic = "kafka.topic"
MetadataKafkaHeaderPrefix = "kafka.header."
)

@@ -97,7 +95,7 @@ func (s *Source) Read(ctx context.Context) (sdk.Record, error) {
return sdk.Record{}, fmt.Errorf("failed getting a record: %w", err)
}

metadata := sdk.Metadata{MetadataKafkaTopic: rec.Topic}
metadata := sdk.Metadata{}
metadata.SetCollection(rec.Topic)
metadata.SetCreatedAt(rec.Timestamp)
for _, h := range rec.Headers {
1 change: 0 additions & 1 deletion source_test.go
Original file line number Diff line number Diff line change
@@ -69,7 +69,6 @@ func TestSource_Read(t *testing.T) {
}.ToSDKPosition(),
Operation: sdk.OperationCreate,
Metadata: map[string]string{
MetadataKafkaTopic: rec.Topic,
sdk.MetadataCollection: rec.Topic,
sdk.MetadataCreatedAt: strconv.FormatInt(rec.Timestamp.UnixNano(), 10),
"kafka.header.header-a": "value-a",
2 changes: 1 addition & 1 deletion test/util.go
Original file line number Diff line number Diff line change
@@ -159,7 +159,7 @@ func GenerateSDKRecords(from, to int) []sdk.Record {
recs := GenerateFranzRecords(from, to)
sdkRecs := make([]sdk.Record, len(recs))
for i, rec := range recs {
metadata := sdk.Metadata{"kafka.topic": rec.Topic}
metadata := sdk.Metadata{}
metadata.SetCollection(rec.Topic)
metadata.SetCreatedAt(rec.Timestamp)