forked from Shopify/ghostferry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter.go
31 lines (27 loc) · 1.38 KB
/
filter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package ghostferry
import (
sq "github.com/Masterminds/squirrel"
)
// CopyFilter provides an interface for restricting the copying to a subset of
// data. This typically involves adding a WHERE condition in the ConstrainSelect
// function, and returning false for unwanted rows in ApplicableEvent.
type CopyFilter interface {
// BuildSelect is used to set up the query used for batch data copying,
// allowing for restricting copying to a subset of data. Returning an error
// here will cause the query to be retried, until the retry limit is
// reached, at which point the ferry will be aborted. BuildSelect is passed
// the columns to be selected, table being copied, the last primary key value
// from the previous batch, and the batch size. Call DefaultBuildSelect to
// generate the default query, which may be used as a starting point.
BuildSelect([]string, *TableSchema, uint64, uint64) (sq.SelectBuilder, error)
// ApplicableEvent is used to filter events for rows that have been
// filtered in ConstrainSelect. ApplicableEvent should return true if the
// event is for a row that would be selected by ConstrainSelect, and false
// otherwise.
// Returning an error here will cause the ferry to be aborted.
ApplicableEvent(DMLEvent) (bool, error)
}
type TableFilter interface {
ApplicableTables([]*TableSchema) ([]*TableSchema, error)
ApplicableDatabases([]string) ([]string, error)
}