-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
disentangle library dependencies by moving to a feature registration …
…design
- Loading branch information
1 parent
f5e4477
commit 7058e81
Showing
16 changed files
with
102 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package lib | ||
|
||
import ( | ||
"fmt" | ||
"sync" | ||
|
||
"github.com/dbsteward/dbsteward/lib/ir" | ||
"github.com/dbsteward/dbsteward/lib/output" | ||
) | ||
|
||
type Operations interface { | ||
Build(outputPrefix string, dbDoc *ir.Definition) error | ||
BuildUpgrade( | ||
oldOutputPrefix, oldCompositeFile string, oldDbDoc *ir.Definition, oldFiles []string, | ||
newOutputPrefix, newCompositeFile string, newDbDoc *ir.Definition, newFiles []string, | ||
) error | ||
ExtractSchema(host string, port uint, name, user, pass string) (*ir.Definition, error) | ||
CompareDbData(dbDoc *ir.Definition, host string, port uint, name, user, pass string) (*ir.Definition, error) | ||
SqlDiff(old, new []string, outputFile string) | ||
|
||
GetQuoter() output.Quoter | ||
} | ||
|
||
type Encoding interface { | ||
} | ||
|
||
var formats = make(map[ir.SqlFormat]func(*DBSteward) Operations) | ||
|
||
var formatMutex sync.Mutex | ||
|
||
func RegisterFormat(id ir.SqlFormat, constructor func(*DBSteward) Operations) { | ||
formatMutex.Lock() | ||
defer formatMutex.Unlock() | ||
formats[id] = constructor | ||
} | ||
|
||
func Format(id ir.SqlFormat) (func(*DBSteward) Operations, error) { | ||
formatMutex.Lock() | ||
defer formatMutex.Unlock() | ||
constructor, exists := formats[id] | ||
if !exists { | ||
return nil, fmt.Errorf("no such format as %s", id) | ||
} | ||
return constructor, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.