-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic stream level metadata to catalog entries
This PR does a few big changes, mainly adding the concept of metadata to the catalog and it's entries. We create and emit a few default fields into entries now that let us specify how we will act for a given stream - users can also edit these values (along with adding others) so we need to read that catalog file back in if specified. When reading it in we parse it back into our catalog object and then use that to try and filter the streams we will act on. The options are a little weird here but basically, a user can set "selected" (we cannot) if the selected is not set, then we can check if "selected-by-default" is set, as this is something we typically control and will have turned on. If none of those match or are false then we don't include the stream. If we do not find a catalog file at all - then we will create our default one (same as running --discover) and just use that immediately.
- Loading branch information
Showing
5 changed files
with
196 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package tap | ||
|
||
import "github.com/incident-io/singer-tap/model" | ||
|
||
type Metadata struct { | ||
// Pointer to where in the schmea this metadata applies | ||
Breadcrumb []string `json:"breadcrumb"` | ||
|
||
// Fields set for this metadata object | ||
Metadata MetadataFields `json:"metadata"` | ||
} | ||
|
||
type MetadataFields struct { | ||
/**** | ||
* NON DISCOVERABLE FIELDS | ||
* We don't control these - pull them in and use them | ||
****/ | ||
|
||
// Selected: if this node is selected by the user to be emitted | ||
// Can be field level or whole stream | ||
Selected *bool `json:"selected,omitempty"` | ||
|
||
// ReplicationMethod: the replication method to use | ||
// we ignored for our tap | ||
ReplicationMethod *string `json:"replicate-method,omitempty"` | ||
|
||
// ReplicationKey: the replicate key for this node | ||
// Used as a bookmark - ignore for our tap | ||
ReplicationKey *string `json:"replication-key,omitempty"` | ||
|
||
// ViewKeyProperties: not sure how this is used | ||
// ignored for our tap | ||
ViewKeyProperties *[]string `json:"view-key-properties,omitempty"` | ||
|
||
/**** | ||
* DISCOVERABLE FIELDS | ||
* We can read and write these fields | ||
****/ | ||
|
||
// Inclusion: whether we emit this field automatically | ||
// can be available (you choose), automatic (we choose), or unsupported (we don't emit) | ||
Inclusion string `json:"inclusion"` | ||
|
||
// SelectedByDefault: If the user doesn't specify should we | ||
// emit this field by default | ||
// This really only applies to available inclusion setting | ||
SelectedByDefault bool `json:"selected-by-default"` | ||
|
||
// ForcedReplicateMethod: we will set to FULL_TABLE for our tap | ||
ForcedReplicationMethod string `json:"forced-replication-method"` | ||
} | ||
|
||
func (m Metadata) DefaultMetadata(schema model.Schema) []Metadata { | ||
// By default we always include a top level metadata with the same | ||
// settings | ||
var metadata = []Metadata{ | ||
{ | ||
Breadcrumb: []string{}, | ||
Metadata: MetadataFields{ | ||
Inclusion: "available", // always set to available at stream level | ||
SelectedByDefault: true, // lets assume people always want our data | ||
ForcedReplicationMethod: "FULL_TABLE", // HIGHWAY TO THE DATA ZONE | ||
}, | ||
}, | ||
} | ||
|
||
return metadata | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters