Skip to content

Commit

Permalink
WIP: feat: add shadow rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Lvnszn committed May 27, 2022
1 parent 2795531 commit 8a2eb21
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
25 changes: 25 additions & 0 deletions conf/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,28 @@ data:
tbl_pattern: student_${0000...0031}
attributes:
sqlMaxLimit: -1

shadow_rule:
data_sources:
- name: shadowDataSource
source_datasource_name: employees
shadow_datasource_name: shadow_employees
tables:
- name: student
datasource_name: shadowDataSource
shadow_algorithm_names:
- simple-hint-algorithm
- user-id-value-match-algorithm
shadow_algorithms:
- name: user-id-insert-match-algorithm
type: VALUE_MATCH
props:
operation: insert
column: user_id
value: 0
- name: user-id-insert-regex-algorithm
type: REGEX_MATCH
props:
operation: insert
column: user_id
regex: 0
32 changes: 32 additions & 0 deletions pkg/config/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type (
Tenants []*Tenant `validate:"required,dive" yaml:"tenants" json:"tenants"`
DataSourceClusters []*DataSourceCluster `validate:"required,dive" yaml:"clusters" json:"clusters"`
ShardingRule *ShardingRule `validate:"required,dive" yaml:"sharding_rule,omitempty" json:"sharding_rule,omitempty"`
ShadowRule *ShadowRule `validate:"required,dive" yaml:"shadow_rule,omitempty" json:"shadow_rule,omitempty"`
}

Filter struct {
Expand Down Expand Up @@ -108,6 +109,37 @@ type (
Tables []*Table `yaml:"tables" json:"tables"`
}

ShadowRule struct {
ShadowSources []*ShadowSource `yaml:"shadow_sources" json:"shadow_sources"`
ShadowTables []*ShadowTable `yaml:"tables" json:"tables"`
ShadowAlgorithms []*ShadowAlgorithm `yaml:"shadow_algorithms" json:"shadow_algorithms"`
}

ShadowSource struct {
Name string `yaml:"name" json:"name"`
SourceDataSourceName string `yaml:"source_data_source_name" json:"source_data_source_name"`
ShadowDataSourceName string `yaml:"shadow_data_source_name" json:"shadow_data_source_name"`
}

ShadowTable struct {
Name string `yaml:"name" json:"name"`
DataSourceName string `yaml:"datasource_name" json:"datasource_name"`
ShadowAlgorithmNames []string `yaml:"shadow_algorithm_names" json:"shadow_algorithm_names"`
}

ShadowAlgorithm struct {
Name string `yaml:"name" json:"name"`
Type string `yaml:"type" json:"type"`
Props Prop `yaml:"props" json:"props"`
}

Prop struct {
Operation string `yaml:"operation" json:"operation"`
Column string `yaml:"column" json:"column"`
Value string `yaml:"value" json:"value"`
Regex string `yaml:"regex" json:"regex"`
}

Listener struct {
ProtocolType string `yaml:"protocol_type" json:"protocol_type"`
SocketAddress *SocketAddress `yaml:"socket_address" json:"socket_address"`
Expand Down

0 comments on commit 8a2eb21

Please sign in to comment.