Exemple #1
0
// newApp creates a new application. function can only be called once
func newApp() *app {
	a := new(app)
	var err error

	// make sure env var CS_DSN is set and points to the appropriate database
	if a.dbc, err = csdb.Connect(); err != nil {
		log.Fatal("MySQL Connect", "err", err)
	}

	if err := config.TableCollection.Init(a.dbc.NewSession()); err != nil {
		log.Fatal("config.TableCollection.Init", "err", err)
	}
	if err := store.TableCollection.Init(a.dbc.NewSession()); err != nil {
		log.Fatal("store.TableCollection.Init", "err", err)
	}

	a.config = config.NewService(config.WithDBStorage(a.dbc.DB))

	// create JSON web token instance
	if a.jwtSrv, err = ctxjwt.NewService(); err != nil {
		log.Fatal("ctxjwt.NewService", "err", err)
	}
	a.jwtSrv.EnableJTI = true

	return a
}
Exemple #2
0
func main() {
	db, dbrConn, err := csdb.Connect()
	codegen.LogFatal(err)
	defer db.Close()
	for _, tStruct := range codegen.ConfigTableToStruct {
		generateStructures(tStruct, db, dbrConn)
	}
}
Exemple #3
0
func newContext() *context {
	dbc, err := csdb.Connect()
	codegen.LogFatal(err)

	return &context{
		wg:        sync.WaitGroup{},
		dbc:       dbc,
		goSrcPath: build.Default.GOPATH + "/src/",
	}
}
Exemple #4
0
func main() {
	defer log.WhenDone().Info("Stats")
	dbc, err := csdb.Connect()
	codegen.LogFatal(err)
	defer dbc.Close()
	var wg sync.WaitGroup

	mageV1, mageV2 := detectMagentoVersion(dbc.NewSession())

	for _, tStruct := range codegen.ConfigTableToStruct {
		go newGenerator(tStruct, dbc, &wg).setMagentoVersion(mageV1, mageV2).run()
	}

	wg.Wait()

	for _, ts := range codegen.ConfigTableToStruct {
		// due to a race condition the codec generator must run after the newGenerator() calls
		runCodec(ts.Package, ts.OutputFile.AppendName("_codec").String(), ts.OutputFile.String())
	}
}
Exemple #5
0
func main() {
	defer log.WhenDone(PkgLog).Info("Stats")
	dbc, err := csdb.Connect()
	codegen.LogFatal(err)
	defer dbc.Close()
	var wg sync.WaitGroup

	mageV1, mageV2 := detectMagentoVersion(dbc.NewSession())

	for _, tStruct := range codegen.ConfigTableToStruct {
		go newGenerator(tStruct, dbc, &wg).setMagentoVersion(mageV1, mageV2).run()
	}

	wg.Wait()

	//	for _, ts := range codegen.ConfigTableToStruct {
	//		// due to a race condition the codec generator must run after the newGenerator() calls
	//		// TODO(cs) fix https://github.com/ugorji/go/issues/92#issuecomment-140410732
	//		runCodec(ts.Package, ts.OutputFile.AppendName("_codec").String(), ts.OutputFile.String())
	//	}
}