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) } }
func main() { // showing 1 way of managing gizmo/config: importing from a local file var cfg *service.Config config.LoadJSONFile("./config.json", &cfg) server.SetConfigOverrides(cfg.Server) server.Init("nyt-rpc-proxy", cfg.Server) err := server.Register(service.NewRPCService(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) } }
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) } }