generated from PackagrIO/goweb-template
-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] adding factory pattern support to Database package.
Users can select database type using database.type configuration when calling NewRepository()
- Loading branch information
Showing
9 changed files
with
61 additions
and
1 deletion.
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
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,18 @@ | ||
package database | ||
|
||
import ( | ||
"github.com/fastenhealth/fasten-onprem/backend/pkg" | ||
"github.com/fastenhealth/fasten-onprem/backend/pkg/config" | ||
"github.com/fastenhealth/fasten-onprem/backend/pkg/errors" | ||
"github.com/fastenhealth/fasten-onprem/backend/pkg/event_bus" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func NewRepository(appConfig config.Interface, globalLogger logrus.FieldLogger, eventBus event_bus.Interface) (DatabaseRepository, error) { | ||
switch pkg.DatabaseRepositoryType(appConfig.GetString("database.type")) { | ||
case pkg.DatabaseRepositoryTypeSqlite: | ||
return newSqliteRepository(appConfig, globalLogger, eventBus) | ||
default: | ||
return nil, errors.DatabaseTypeNotSupportedError(appConfig.GetString("database.type")) | ||
} | ||
} |
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