Documentation
¶
Index ¶
- func BuildPeerConfig(ctx context.Context, encKeyID string, encPeerOptions []byte, peerName string, ...) (*protos.Peer, error)
- func GetAs[T Connector](ctx context.Context, env map[string]string, config *protos.Peer) (T, func(context.Context), error)
- func GetByNameAs[T Connector](ctx context.Context, env map[string]string, catalogPool shared.CatalogPool, ...) (T, func(context.Context), error)
- func GetByNameWithCDCDestinationTypeAs[T Connector](ctx context.Context, env map[string]string, catalogPool shared.CatalogPool, ...) (T, func(context.Context), error)
- func GetPostgresConnectorByName(ctx context.Context, env map[string]string, catalogPool shared.CatalogPool, ...) (*connpostgres.PostgresConnector, func(context.Context), error)
- func LoadPeer(ctx context.Context, catalogPool shared.CatalogPool, peerName string) (*protos.Peer, error)
- func LoadPeerAndGetByNameAs[T Connector](ctx context.Context, env map[string]string, catalogPool shared.CatalogPool, ...) (*protos.Peer, T, func(context.Context), error)
- func LoadPeerType(ctx context.Context, catalogPool shared.CatalogPool, peerName string) (protos.DBType, error)
- func LoadPeerTypes(ctx context.Context, catalogPool shared.CatalogPool, peerNames []string) (map[string]protos.DBType, error)
- func LoadPeers(ctx context.Context, catalogPool shared.CatalogPool, peerNames []string) (map[string]*protos.Peer, error)
- type CDCNormalizeConnector
- type CDCPullConnector
- type CDCPullConnectorCore
- type CDCPullPgConnector
- type CDCSyncConnector
- type CDCSyncConnectorCore
- type CDCSyncPgConnector
- type Connector
- type CreateTablesFromExistingConnector
- type DatabaseVariantConnector
- type GetFlagsConnector
- type GetLogRetentionConnector
- type GetSchemaConnector
- type GetServerSideCommitLagConnector
- type GetTableSchemaConnector
- type GetVersionConnector
- type MirrorDestinationValidationConnector
- type MirrorSourceValidationConnector
- type NormalizedTablesConnector
- type QRepConsolidateConnector
- type QRepPullConnector
- type QRepPullConnectorCore
- type QRepPullObjectsConnector
- type QRepSyncConnector
- type QRepSyncConnectorCore
- type QRepSyncObjectsConnector
- type QRepSyncPgConnector
- type RawTableConnector
- type RenameTablesConnector
- type RenameTablesWithSoftDeleteConnector
- type ReplicationMechanismInUseConnector
- type SourceClockOffsetConnector
- type StatActivityConnector
- type TableSizeEstimatorConnector
- type ValidationConnector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildPeerConfig ¶
func GetAs ¶
func GetAs[T Connector](ctx context.Context, env map[string]string, config *protos.Peer) (T, func(context.Context), error)
Gets typed connector by config. Returns a close function to recruit the compiler into helping us avoid connection leaks.
func GetByNameAs ¶
func GetByNameAs[T Connector]( ctx context.Context, env map[string]string, catalogPool shared.CatalogPool, name string, ) (T, func(context.Context), error)
Gets connector by name. Returns a close function to recruit the compiler into helping us avoid connection leaks.
func GetByNameWithCDCDestinationTypeAs ¶
func GetByNameWithCDCDestinationTypeAs[T Connector]( ctx context.Context, env map[string]string, catalogPool shared.CatalogPool, name string, destinationType protos.DBType, ) (T, func(context.Context), error)
Gets connector by name, aware of CDC destination connector type. Returns a close function to recruit the compiler into helping us avoid connection leaks.
func GetPostgresConnectorByName ¶
func GetPostgresConnectorByName( ctx context.Context, env map[string]string, catalogPool shared.CatalogPool, name string, ) (*connpostgres.PostgresConnector, func(context.Context), error)
Gets Postgres connector by name. Returns a close function to recruit the compiler into helping us avoid connection leaks.
func LoadPeerAndGetByNameAs ¶
func LoadPeerAndGetByNameAs[T Connector]( ctx context.Context, env map[string]string, catalogPool shared.CatalogPool, name string, ) (*protos.Peer, T, func(context.Context), error)
Gets peer and connector by name. Returns a close function to recruit the compiler into helping us avoid connection leaks.
func LoadPeerType ¶
func LoadPeerTypes ¶
Types ¶
type CDCNormalizeConnector ¶
type CDCNormalizeConnector interface {
Connector
// NormalizeRecords merges records pushed earlier into the destination table.
// This method should be idempotent, and should be able to be called multiple times with the same request.
NormalizeRecords(ctx context.Context, req *model.NormalizeRecordsRequest) (model.NormalizeResponse, error)
}
type CDCPullConnector ¶
type CDCPullConnector interface {
CDCPullConnectorCore
// This method should be idempotent, and should be able to be called multiple times with the same request.
PullRecords(
ctx context.Context,
catalogPool shared.CatalogPool,
otelManager *otel_metrics.OtelManager,
req *model.PullRecordsRequest[model.RecordItems],
) error
}
type CDCPullConnectorCore ¶
type CDCPullConnectorCore interface {
GetTableSchemaConnector
// EnsurePullability ensures that the connector is pullable.
EnsurePullability(ctx context.Context, req *protos.EnsurePullabilityBatchInput) (
*protos.EnsurePullabilityBatchOutput, error)
// For InitialSnapshotOnly correctness without replication slot
// `any` is for returning transaction if necessary
ExportTxSnapshot(
ctx context.Context,
flowName string,
env map[string]string,
) (*protos.ExportTxSnapshotOutput, any, error)
// `any` from ExportSnapshot passed here when done, allowing transaction to commit
FinishExport(any) error
// Setup replication in prep for initial copy
SetupReplication(context.Context, shared.CatalogPool, *protos.SetupReplicationInput) (model.SetupReplicationResult, error)
// Methods related to retrieving and pushing records for this connector as a source and destination.
SetupReplConn(context.Context, map[string]string) error
// Called when offset has been confirmed to destination
UpdateReplStateLastOffset(ctx context.Context, lastOffset model.CdcCheckpoint) error
// PullFlowCleanup drops both the Postgres publication and replication slot, as a part of DROP MIRROR
PullFlowCleanup(ctx context.Context, jobName string) error
}
type CDCPullPgConnector ¶
type CDCPullPgConnector interface {
CDCPullConnectorCore
// This method should be idempotent, and should be able to be called multiple times with the same request.
// It's signature, aside from type parameter, should match CDCPullConnector.PullRecords.
PullPg(
ctx context.Context,
catalogPool shared.CatalogPool,
otelManager *otel_metrics.OtelManager,
req *model.PullRecordsRequest[model.PgItems],
) error
}
type CDCSyncConnector ¶
type CDCSyncConnector interface {
CDCSyncConnectorCore
// SyncRecords pushes RecordItems to the destination peer and stores it in PeerDB specific tables.
// This method should be idempotent, and should be able to be called multiple times with the same request.
SyncRecords(ctx context.Context, req *model.SyncRecordsRequest[model.RecordItems]) (*model.SyncResponse, error)
}
type CDCSyncConnectorCore ¶
type CDCSyncConnectorCore interface {
Connector
// NeedsSetupMetadataTables checks if the metadata table [PEERDB_MIRROR_JOBS] needs to be created.
NeedsSetupMetadataTables(ctx context.Context) (bool, error)
// SetupMetadataTables creates the metadata table [PEERDB_MIRROR_JOBS] if necessary.
SetupMetadataTables(ctx context.Context) error
// GetLastSyncBatchID gets the last batch synced to the destination from the metadata table
GetLastSyncBatchID(ctx context.Context, jobName string) (int64, error)
// CreateRawTable creates a raw table for the connector with a given name and a fixed schema.
CreateRawTable(ctx context.Context, req *protos.CreateRawTableInput) (*protos.CreateRawTableOutput, error)
// SyncFlowCleanup drops metadata tables on the destination, as a part of DROP MIRROR.
SyncFlowCleanup(ctx context.Context, jobName string) error
// ReplayTableSchemaDelta changes a destination table to match the schema at source
// This could involve adding multiple columns.
// Connectors which are non-normalizing should implement this as a nop.
ReplayTableSchemaDeltas(ctx context.Context, env map[string]string, flowJobName string,
tableMappings []*protos.TableMapping, schemaDeltas []*protos.TableSchemaDelta, flags []string,
) error
}
type CDCSyncPgConnector ¶
type CDCSyncPgConnector interface {
CDCSyncConnectorCore
// SyncPg pushes PgItems to the destination peer and stores it in PeerDB specific tables.
// This method should be idempotent, and should be able to be called multiple times with the same request.
// It's signature, aside from type parameter, should match CDCSyncConnector.SyncRecords.
SyncPg(ctx context.Context, req *model.SyncRecordsRequest[model.PgItems]) (*model.SyncResponse, error)
}
type CreateTablesFromExistingConnector ¶
type CreateTablesFromExistingConnector interface {
Connector
CreateTablesFromExisting(context.Context, *protos.CreateTablesFromExistingInput) (*protos.CreateTablesFromExistingOutput, error)
}
type GetFlagsConnector ¶
type GetSchemaConnector ¶
type GetSchemaConnector interface {
Connector
GetAllTables(context.Context) (*protos.AllTablesResponse, error)
GetColumns(ctx context.Context, version uint32, schema string, table string) (*protos.TableColumnsResponse, error)
GetSchemas(ctx context.Context) (*protos.PeerSchemasResponse, error)
GetTablesInSchema(ctx context.Context, schema string, cdcEnabled bool) (*protos.SchemaTablesResponse, error)
}
type GetTableSchemaConnector ¶
type GetTableSchemaConnector interface {
Connector
// GetTableSchema returns the schema of a table in terms of type system.
GetTableSchema(
ctx context.Context,
env map[string]string,
version uint32,
system protos.TypeSystem,
tableMappings []*protos.TableMapping,
) (map[string]*protos.TableSchema, error)
}
type GetVersionConnector ¶
type MirrorDestinationValidationConnector ¶
type MirrorDestinationValidationConnector interface {
Connector
ValidateMirrorDestination(context.Context, *protos.FlowConnectionConfigsCore, map[string]*protos.TableSchema) error
}
type MirrorSourceValidationConnector ¶
type MirrorSourceValidationConnector interface {
GetTableSchemaConnector
// ValidateMirrorSource checks that the source is ready to replicate the configured tables.
// MUST return *common.SourceTablesMissingError when a mapped source table is absent.
ValidateMirrorSource(context.Context, *protos.FlowConnectionConfigsCore) error
}
type NormalizedTablesConnector ¶
type NormalizedTablesConnector interface {
Connector
// StartSetupNormalizedTables may be used to have SetupNormalizedTable calls run in a transaction.
StartSetupNormalizedTables(ctx context.Context) (any, error)
// CleanupSetupNormalizedTables may be used to rollback transaction started by StartSetupNormalizedTables.
// Calling CleanupSetupNormalizedTables after FinishSetupNormalizedTables must be a nop.
CleanupSetupNormalizedTables(ctx context.Context, tx any)
// FinishSetupNormalizedTables may be used to finish transaction started by StartSetupNormalizedTables.
FinishSetupNormalizedTables(ctx context.Context, tx any) error
// SetupNormalizedTable sets up the normalized table on the connector.
SetupNormalizedTable(
ctx context.Context,
tx any,
config *protos.SetupNormalizedTableBatchInput,
destinationTableIdentifier string,
sourceTableSchema *protos.TableSchema,
) (bool, error)
}
type QRepConsolidateConnector ¶
type QRepConsolidateConnector interface {
Connector
// ConsolidateQRepPartitions consolidates the partitions for a given table.
ConsolidateQRepPartitions(ctx context.Context, config *protos.QRepConfig) error
// CleanupQRepFlow cleans up the QRep flow for a given table.
CleanupQRepFlow(ctx context.Context, config *protos.QRepConfig) error
}
type QRepPullConnector ¶
type QRepPullConnector interface {
QRepPullConnectorCore
// PullQRepRecords returns the records for a given partition.
PullQRepRecords(
context.Context, shared.CatalogPool, *otel_metrics.OtelManager, *protos.QRepConfig, protos.DBType, *protos.QRepPartition,
*model.QRecordStream,
) (int64, int64, error)
}
type QRepPullConnectorCore ¶
type QRepPullConnectorCore interface {
Connector
// GetQRepPartitions returns the partitions for a given table that haven't been synced yet.
GetQRepPartitions(ctx context.Context, config *protos.QRepConfig, last *protos.QRepPartition) ([]*protos.QRepPartition, error)
GetDefaultPartitionKeyForTables(ctx context.Context,
input *protos.GetDefaultPartitionKeyForTablesInput) (*protos.GetDefaultPartitionKeyForTablesOutput, error)
}
type QRepPullObjectsConnector ¶
type QRepPullObjectsConnector interface {
QRepPullConnectorCore
PullQRepObjects(
context.Context,
shared.CatalogPool,
*otel_metrics.OtelManager,
*protos.QRepConfig,
protos.DBType,
*protos.QRepPartition,
*model.QObjectStream,
) (int64, int64, error)
}
type QRepSyncConnector ¶
type QRepSyncConnector interface {
QRepSyncConnectorCore
// SyncQRepRecords syncs the records for a given partition.
// returns the number of records synced and a slice of warnings to report to the user.
SyncQRepRecords(ctx context.Context, config *protos.QRepConfig, partition *protos.QRepPartition,
stream *model.QRecordStream) (int64, shared.QRepWarnings, error)
}
type QRepSyncConnectorCore ¶
type QRepSyncConnectorCore interface {
Connector
// IsQRepPartitionSynced returns true if a partition has already been synced
IsQRepPartitionSynced(ctx context.Context, req *protos.IsQRepPartitionSyncedInput) (bool, error)
// SetupQRepMetadataTables sets up the metadata tables for QRep.
SetupQRepMetadataTables(ctx context.Context, config *protos.QRepConfig) error
}
type QRepSyncObjectsConnector ¶
type QRepSyncObjectsConnector interface {
QRepSyncConnectorCore
SyncQRepObjects(context.Context, *protos.QRepConfig, *protos.QRepPartition, *model.QObjectStream) (int64, shared.QRepWarnings, error)
}
type QRepSyncPgConnector ¶
type QRepSyncPgConnector interface {
QRepSyncConnectorCore
// SyncPgQRepRecords syncs the records for a given partition.
// returns the number of records synced and a slice of warnings to report to the user.
SyncPgQRepRecords(ctx context.Context, config *protos.QRepConfig, partition *protos.QRepPartition,
stream connpostgres.PgCopyReader) (int64, shared.QRepWarnings, error)
}
type RawTableConnector ¶
type RenameTablesConnector ¶
type RenameTablesConnector interface {
Connector
RenameTables(context.Context, *protos.RenameTablesInput) (*protos.RenameTablesOutput, error)
}
type RenameTablesWithSoftDeleteConnector ¶
type RenameTablesWithSoftDeleteConnector interface {
Connector
RenameTables(context.Context, *protos.RenameTablesInput, map[string]*protos.TableSchema) (*protos.RenameTablesOutput, error)
}
type SourceClockOffsetConnector ¶
type SourceClockOffsetConnector interface {
Connector
SourceClockOffset(ctx context.Context) (time.Duration, error)
}
SourceClockOffsetConnector exposes the source connector's estimated clock offset (source clock minus worker clock).
type StatActivityConnector ¶
type StatActivityConnector interface {
Connector
StatActivity(context.Context, *protos.PostgresPeerActivityInfoRequest) (*protos.PeerStatResponse, error)
}