-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: sp db adds service config interface (#164)
* feat: sp db adds service config interface * fix: add table name * fix: fix get db error --------- Co-authored-by: DylanYong <dylan.y@nodereal.io> Main refactor (#166) * chore: add spdb address in env var * fix: stone node replicate idx * refactor: the entry and config * fix: ci lint error
- Loading branch information
1 parent
7c8db50
commit 243bc03
Showing
33 changed files
with
550 additions
and
256 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
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,25 @@ | ||
package utils | ||
|
||
import ( | ||
"github.com/bnb-chain/greenfield-storage-provider/config" | ||
"github.com/bnb-chain/greenfield-storage-provider/store/sqldb" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
// MakeSPDB return sp db instance | ||
func MakeSPDB(ctx *cli.Context) (*sqldb.SpDBImpl, error) { | ||
spDBCfg := config.DefaultSQLDBConfig | ||
if ctx.IsSet(ctx.String(DBUserFlag.Name)) { | ||
spDBCfg.User = ctx.String(DBUserFlag.Name) | ||
} | ||
if ctx.IsSet(ctx.String(DBPasswordFlag.Name)) { | ||
spDBCfg.Passwd = ctx.String(DBPasswordFlag.Name) | ||
} | ||
if ctx.IsSet(ctx.String(DBAddressFlag.Name)) { | ||
spDBCfg.Address = ctx.String(DBAddressFlag.Name) | ||
} | ||
if ctx.IsSet(ctx.String(DBDataBaseFlag.Name)) { | ||
spDBCfg.Database = ctx.String(DBDataBaseFlag.Name) | ||
} | ||
return sqldb.NewSpDB(spDBCfg) | ||
} |
Oops, something went wrong.