-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
370 additions
and
3 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
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 cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/Bnei-Baruch/mdb/importer/dgima" | ||
) | ||
|
||
func init() { | ||
command := &cobra.Command{ | ||
Use: "dgima-import", | ||
Short: "Import capture labels data", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
dgima.Import() | ||
}, | ||
} | ||
RootCmd.AddCommand(command) | ||
} |
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,51 @@ | ||
package dgima | ||
|
||
import ( | ||
"context" | ||
"database/sql" | ||
"time" | ||
|
||
log "github.com/Sirupsen/logrus" | ||
"github.com/spf13/viper" | ||
"github.com/volatiletech/sqlboiler/boil" | ||
|
||
"github.com/Bnei-Baruch/mdb/api" | ||
"github.com/Bnei-Baruch/mdb/events" | ||
"github.com/Bnei-Baruch/mdb/utils" | ||
) | ||
|
||
var ( | ||
mdb *sql.DB | ||
) | ||
|
||
func Init() (time.Time, *events.BufferedEmitter) { | ||
var err error | ||
clock := time.Now() | ||
|
||
log.SetFormatter(&log.TextFormatter{FullTimestamp: true}) | ||
//log.SetLevel(log.WarnLevel) | ||
|
||
log.Info("Starting capture labels import") | ||
|
||
log.Info("Setting up connection to MDB") | ||
mdb, err = sql.Open("postgres", viper.GetString("mdb.url")) | ||
utils.Must(err) | ||
utils.Must(mdb.Ping()) | ||
boil.SetDB(mdb) | ||
//boil.DebugMode = true | ||
|
||
log.Info("Initializing static data from MDB") | ||
utils.Must(api.InitTypeRegistries(mdb)) | ||
|
||
log.Info("Setting events handler") | ||
emitter, err := events.InitEmitter() | ||
utils.Must(err) | ||
|
||
return clock, emitter | ||
} | ||
|
||
func Shutdown() { | ||
ctx, _ := context.WithTimeout(context.Background(), 30*time.Second) | ||
events.CloseEmitter(ctx) | ||
utils.Must(mdb.Close()) | ||
} |
Oops, something went wrong.