Skip to content

Commit

Permalink
Allow applyer to have registry
Browse files Browse the repository at this point in the history
  • Loading branch information
araddon committed Oct 31, 2017
1 parent a94029c commit c4fe1e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions schema/apply_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ type (
// schema changes such as Alters. In distributed db's this is very, very huge part
// of work so is a very important interface that is under flux.
Applyer interface {
// Init initialize the applyer with registry.
Init(r *Registry)
// AddOrUpdateOnSchema Add or Update object (Table, Index)
AddOrUpdateOnSchema(s *Schema, obj interface{}) error
}
Expand All @@ -22,6 +24,7 @@ type (
// schema come in (such as ALTER statements, new tables, new databases)
// we need to apply them to the underlying schema.
InMemApplyer struct {
reg *Registry
schemaSource SchemaSourceProvider
}
)
Expand All @@ -33,6 +36,9 @@ func NewApplyer(sp SchemaSourceProvider) Applyer {
schemaSource: sp,
}
}
func (m *InMemApplyer) Init(r *Registry) {
m.reg = r
}

// AddOrUpdateOnSchema we have a schema change to apply. A schema change is
// a new table, index, or whole new schema being registered. We provide the first
Expand Down
1 change: 1 addition & 0 deletions schema/schemaregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type (
// CreateDefaultRegistry create the default registry.
func CreateDefaultRegistry(applyer Applyer) {
registry = NewRegistry(applyer)
applyer.Init(registry)
}

// OpenConn a schema-source Connection, Global open connection function using
Expand Down

0 comments on commit c4fe1e5

Please sign in to comment.