-
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.
Remove all global variables and disentangle library dependendies by u…
…sing a registration pattern
- Loading branch information
1 parent
2998703
commit df1df48
Showing
42 changed files
with
505 additions
and
579 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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.