Esempio n. 1
0
func main() {
	// load from the local JSON file into a config.Config struct
	cfg := combined.NewConfig("./config.json")
	// SetConfigOverrides will allow us to override some of the values in
	// the JSON file with CLI flags.
	server.SetConfigOverrides(cfg.Server)

	// initialize Gizmo’s server with given configs
	server.Init("nyt-saved-items", cfg.Server)

	// instantiate a new ‘saved items service’ with our MySQL credentials
	svc, err := service.NewSavedItemsService(cfg.MySQL)
	if err != nil {
		server.Log.Fatal("unable to create saved items service: ", err)
	}

	// register our saved item service with the Gizmo server
	err = server.Register(svc)
	if err != nil {
		server.Log.Fatal("unable to register saved items service: ", err)
	}

	// run the Gizmo server
	err = server.Run()
	if err != nil {
		server.Log.Fatal("unable to run saved items service: ", err)
	}
}
Esempio n. 2
0
func main() {
	// showing 1 way of managing gizmo/config: importing from a local file
	cfg := combined.NewConfig("./config.json")

	server.Init("nyt-json-pub-proxy", cfg.Server)

	err := server.Register(service.NewJSONPubService(cfg))
	if err != nil {
		server.Log.Fatal("unable to register service: ", err)
	}

	err = server.Run()
	if err != nil {
		server.Log.Fatal("server encountered a fatal error: ", err)
	}
}
Esempio n. 3
0
File: main.go Progetto: strogo/gizmo
func main() {
	// showing 1 way of managing gizmo/config: importing from a local file
	var cfg *service.Config
	config.LoadJSONFile("./config.json", &cfg)

	server.Init("nyt-most-popular-json-proxy", cfg.Server)

	err := server.Register(service.NewJSONService(cfg))
	if err != nil {
		server.Log.Fatal("unable to register service: ", err)
	}

	err = server.Run()
	if err != nil {
		server.Log.Fatal("server encountered a fatal error: ", err)
	}
}
Esempio n. 4
0
File: main.go Progetto: slok/khronos
func main() {
	// Get config location file
	configFile := os.Getenv(config.KhronosConfigFileKey)

	// Load config
	cfg := config.NewAppConfig(configFile)
	server.Init("khronos", cfg.Server)

	var stCli storage.Client
	var err error

	// Create the storage client
	switch cfg.StorageEngine {
	case "dummy":
		stCli = storage.NewDummy()
	case "boltdb":
		to := time.Duration(cfg.BoltDBTimeoutSeconds)
		stCli, err = storage.NewBoltDB(cfg.BoltDBPath, to)
		if err != nil {
			logrus.Fatalf("Error opening boltdb database: %v", err)
		}
	default:
		logrus.Fatal("Wrong Storage engine")
	}

	// Create scheduler and start
	cr := schedule.NewDummyCron(cfg, stCli, 0, "OK")
	cr.Start(nil)
	defer cr.Stop()

	// Load service
	khronosService := service.NewKhronosService(cfg, stCli, cr)

	// Register the service on the server
	err = server.Register(khronosService)
	if err != nil {
		logrus.Fatalf("unable to register service: %v", err)
	}

	// Serve our service
	err = server.Run()
	if err != nil {
		logrus.Fatalf("server encountered a fatal error: %v", err)
	}
}
Esempio n. 5
0
File: main.go Progetto: strogo/gizmo
func main() {
	// showing 1 way of managing gizmo/config: importing from the environment
	cfg := service.Config{Server: &config.Server{}}
	config.LoadEnvConfig(&cfg)
	config.LoadEnvConfig(cfg.Server)

	server.Init("nyt-simple-proxy", cfg.Server)

	err := server.Register(service.NewSimpleService(&cfg))
	if err != nil {
		server.Log.Fatal("unable to register service: ", err)
	}

	err = server.Run()
	if err != nil {
		server.Log.Fatal("server encountered a fatal error: ", err)
	}
}
Esempio n. 6
0
func main() {
	cfg := combined.NewConfig("./config.json")

	// set the pubsub's Log to be the same as server's
	pubsub.Log = server.Log

	// in case we want to override the port or log location via CLI
	server.SetConfigOverrides(cfg.Server)

	server.Init("gamestream-example", cfg.Server)

	err := server.Register(service.NewStreamService(cfg.Server.HTTPPort, cfg.Kafka))
	if err != nil {
		server.Log.Fatal(err)
	}

	if err = server.Run(); err != nil {
		server.Log.Fatal(err)
	}
}
Esempio n. 7
0
func main() {
	var cfg *service.Config
	config.LoadJSONFile("./config.json", &cfg)
	server.Init("gizmo-boilerplate", cfg.Server)
	dbSql, err := cfg.MySQL.DB()
	if err != nil {
		server.Log.Fatal("unable to connect to mysql ", err)
	}
	cfg.DB, _ = gorm.Open("mysql", dbSql)
	mongoSess := cfg.MongoDB.MustMaster()
	cfg.Mongo = mongoSess.DB(cfg.MongoDB.DB)
	err = server.Register(service.NewJSONService(cfg))
	if err != nil {
		server.Log.Fatal("unable to register service: ", err)
	}

	err = server.Run()
	if err != nil {
		server.Log.Fatal("server encountered a fatal error: ", err)
	}
}