func Init() { var cfg *Config config.LoadJSONFile("./config.json", &cfg) config.SetLogOverride(cfg.Log) if *cfg.Log != "" { lf, err := logrotate.NewFile(*cfg.Log) if err != nil { Log.Fatalf("unable to access log file: %s", err) } Log.Out = lf Log.Formatter = &logrus.JSONFormatter{} } else { Log.Out = os.Stderr } pubsub.Log = Log var err error cfg.Metrics.Prefix = metricsNamespace() metrics, err = cfg.Metrics.NewProvider() if err != nil { Log.Fatal("unable to init metrics: ", err) } client = nyt.NewClient(cfg.MostPopularToken, cfg.SemanticToken) sub, err = aws.NewSubscriber(cfg.SQS) if err != nil { Log.Fatal("unable to init SQS: ", err) } }
func Init() { flag.Parse() var cfg *Config config.LoadJSONFile("./config.json", &cfg) config.SetLogOverride(cfg.Log) if *cfg.Log != "" { lf, err := logrotate.NewFile(*cfg.Log) if err != nil { Log.Fatalf("unable to access log file: %s", err) } Log.Out = lf Log.Formatter = &logrus.JSONFormatter{} } else { Log.Out = os.Stderr } pubsub.Log = Log if cfg.GraphiteHost != nil { initMetrics(*cfg.GraphiteHost) } client = nyt.NewClient(cfg.MostPopularToken, cfg.SemanticToken) var err error sub, err = pubsub.NewSQSSubscriber(cfg.SQS) if err != nil { Log.Fatal("unable to init pb subs SQS: ", err) } }
// NewSimpleService will instantiate a SimpleService // with the given configuration. func NewSimpleService(cfg *Config) *SimpleService { return &SimpleService{ nyt.NewClient(cfg.MostPopularToken, cfg.SemanticToken), } }
// NewRPCService will instantiate a RPCService // with the given configuration. func NewRPCService(cfg *Config) *RPCService { return &RPCService{ nyt.NewClient(cfg.MostPopularToken, cfg.SemanticToken), } }
// NewMixedService will instantiate a MixedService // with the given configuration. func NewMixedService(cfg *Config) *MixedService { return &MixedService{ nyt.NewClient(cfg.MostPopularToken, cfg.SemanticToken), } }