---
name: test # global unique
task-mode: all  # full/incremental/all
is-sharding: true  # whether multi dm-worker do one sharding job
meta-schema: "dm_meta"  # meta schema in downstreaming database to store meta informaton of dm
enable-heartbeat: false  # whether to enable heartbeat for calculating lag between master and syncer
# heartbeat-update-interval: 1  # interval to do heartbeat and save timestamp, default 1s
# heartbeat-report-interval: 10 # interval to report time lap to prometheus, default 10s

target-database:
  host: "192.168.0.1"
  port: 4000
  user: "root"
  password: ""

mysql-instances:             # one or more source database, config more source database for sharding merge
  -
    source-id: "instance118-4306" # unique in all instances, used as id when save checkpoints, configs, etc.

    # binlog pos used to as start pos for syncer, for different task-mode, this maybe used or not
    # `full` / `all`:
    #    never be used
    # `incremental`:
    #    if checkpoints already exists in `meta-schema`, this will not be used
    #    otherwise, this will be used
    meta:
      binlog-name: mysql-bin.000001
      binlog-pos: 4
    route-rules: ["user-route-rules-schema", "user-route-rules"]
    filter-rules: ["user-filter-1", "user-filter-2"]
    block-allow-list:  "instance"

    # `mydumper-config-name` and `mydumper` should only set one
    mydumper-config-name: "global"   # ref `mydumpers` config
    # `mydumper-thread` is alias for `threads` in `mydumper` config, and its priority is higher than `threads`
    #mydumper-thread: 16
    #mydumper:
    #  threads: 16

    # `loader-config-name` and `loader` should only set one
    loader-config-name: "global"    # ref `loaders` config
    # `loader-thread` is alias for `pool-size` in `loader` config, and its priority is higher than `pool-size`
    #loader-thread: 32
    #loader:                  # local loader rule
    #  pool-size: 32
    # `syncer-config-name` and `syncer` should only set one

    syncer-config-name: "global"    # ref `syncers` config
    # `syncer-thread` is alias for `worker-count` in `syncer` config, and its priority is higher than `worker-count`
    #syncer-thread: 32
    #syncer:
    #  worker-count: 32

  -
    source-id: "instance118-5306"
    meta:
      binlog-name: mysql-bin.000001
      binlog-pos: 320
    route-rules: ["user-route-rules-schema", "user-route-rules"]
    filter-rules: ["user-filter-2"]
    block-allow-list: "instance"

    mydumper:
      threads: 4
      chunk-filesize: 64
      skip-tz-utc: true
#      extra-args: "-B test -T t1,t2"

    loader:                  # local loader rule
      pool-size: 16
      dir: "./dumped_data"   # if not ends with `.{name}` (`{name}` is the task name), then `.{name}` will be appended

    syncer:
      worker-count: 16
      batch: 100

# other common configs shared by all instances

routes:                      # schema/table route mapping
  user-route-rules-schema:
    schema-pattern: "test_*"    # pattern of the upstream schema name, wildcard characters (*?) are supported
    target-schema: "test"       # downstream schema name
  user-route-rules:
    schema-pattern: "test_*"
    table-pattern: "t_*"        # pattern of the upstream table name, wildcard characters (*?) are supported
    target-schema: "test"
    target-table: "t"           # downstream table name

filters:                     # filter rules, mysql instance can ref rules in it
  user-filter-1:
    schema-pattern: "test_*"    # pattern of the upstream schema name, wildcard characters (*?) are supported
    table-pattern: "t_*"        # pattern of the upstream table name, wildcard characters (*?) are supported
    events: ["truncate table", "drop table"]  # ignore truncate/drop table ddl
    # pattern of the SQL statements, regular expression is supported
    # when using global filtering rule (`schema-pattern: "*"`), it will try to match the original statement executed in the upstream
    # when not using global filtering rule, it will try to match the statement parsed/restored by DM without route-rules applied (can find it in the log)
    sql-pattern: ["^DROP\\s+PROCEDURE", "^CREATE\\s+PROCEDURE"]
    action: Ignore
  user-filter-2:
    schema-pattern: "test_*"
    events: ["all dml"]             # only do all DML events
    action: Do

block-allow-list:
  instance:
    do-dbs: ["~^test.*", "do"]        # allow list of upstream schemas needs to be replicated, regular expression (starts with ~) is supported
    ignore-dbs: ["mysql", "ignored"]  # block list of upstream schemas needs to be replicated, regular expression (starts with ~) is supported
    do-tables:                        # allow list of upstream tables needs to be replicated, (db-name, tbl-name) regular expression (starts with ~) is supported
    - db-name: "~^test.*"
      tbl-name: "~^t.*"
    - db-name: "do"
      tbl-name: "do"
    ignore-tables:                    # block list of upstream tables needs to be replicated, (db-name, tbl-name) regular expression (starts with ~) is supported
    - db-name: "test"
      tbl-name: "log"

mydumpers:                   # mydumper process unit specific configs, mysql instance can ref one config in it
  global:
    threads: 4
    chunk-filesize: 64
    skip-tz-utc: true
    extra-args: "-B test -T t1,t2 --consistency none"

loaders:                     # loader process unit specific configs, mysql instance can ref one config in it
  global:
    pool-size: 16
    dir: "./dumped_data"

syncers:                     # syncer process unit specific configs, mysql instance can ref one config in it
  global:
    worker-count: 16
    batch: 100
