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

Metadata constants + opencdc.collection #31

Merged
merged 2 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 15 additions & 1 deletion opencdc/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ const (
// read from the 3rd party system. The expected format is a unix timestamp
// in nanoseconds.
MetadataReadAt = "opencdc.readAt"
// MetadataCollection is a Record.Metadata key for the name of the collection
// where the record originated from and/or where it should be stored.
MetadataCollection = "opencdc.collection"

// MetadataConduitSourcePluginName is a Record.Metadata key for the name of
// the source plugin that created this record.
Expand All @@ -57,7 +60,7 @@ const (
MetadataConduitDestinationPluginVersion = "conduit.destination.plugin.version"

// MetadataConduitSourceConnectorID is a Record.Metadata key for the ID of
// the source connector that received this record.
// the source connector that produced this record.
MetadataConduitSourceConnectorID = "conduit.source.connector.id"
// MetadataConduitDLQNackError is a Record.Metadata key for the error that
// caused a record to be nacked and pushed to the dead-letter queue.
Expand Down Expand Up @@ -130,6 +133,17 @@ func (m Metadata) SetReadAt(createdAt time.Time) {
m[MetadataReadAt] = strconv.FormatInt(createdAt.UnixNano(), 10)
}

// GetCollection returns the value for key MetadataCollection. If the value does
// not exist or is empty the function returns ErrMetadataFieldNotFound.
func (m Metadata) GetCollection() (string, error) {
return m.getValue(MetadataCollection)
}

// SetCollection sets the metadata value for key MetadataCollection.
func (m Metadata) SetCollection(collection string) {
m[MetadataCollection] = collection
}

// GetConduitSourcePluginName returns the value for key
// MetadataConduitSourcePluginName. If the value does not exist or is empty the
// function returns ErrMetadataFieldNotFound.
Expand Down
10 changes: 10 additions & 0 deletions opencdc/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package opencdc
import (
"testing"

metadatav1 "github.com/conduitio/conduit-commons/proto/metadata/v1"
opencdcv1 "github.com/conduitio/conduit-commons/proto/opencdc/v1"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/runtime/protoimpl"
Expand All @@ -28,6 +29,15 @@ func TestMetadataConstants(t *testing.T) {
MetadataOpenCDCVersion: opencdcv1.E_MetadataVersion,
MetadataCreatedAt: opencdcv1.E_MetadataCreatedAt,
MetadataReadAt: opencdcv1.E_MetadataReadAt,
MetadataCollection: opencdcv1.E_MetadataCollection,

MetadataConduitSourcePluginName: metadatav1.E_MetadataConduitSourcePluginName,
MetadataConduitSourcePluginVersion: metadatav1.E_MetadataConduitSourcePluginVersion,
MetadataConduitDestinationPluginName: metadatav1.E_MetadataConduitDestinationPluginName,
MetadataConduitDestinationPluginVersion: metadatav1.E_MetadataConduitDestinationPluginVersion,
MetadataConduitSourceConnectorID: metadatav1.E_MetadataConduitSourceConnectorId,
MetadataConduitDLQNackError: metadatav1.E_MetadataConduitDlqNackError,
MetadataConduitDLQNackNodeID: metadatav1.E_MetadataConduitDlqNackNodeId,
}
for goConstant, extensionInfo := range wantMapping {
protoConstant := proto.GetExtension(extensionInfo.TypeDescriptor().ParentFile().Options(), extensionInfo)
Expand Down
249 changes: 249 additions & 0 deletions proto/metadata/v1/constants.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading