예제 #1
0
파일: main.go 프로젝트: ycaihua/gizmo
func main() {
	cfg := aws.LoadSNSConfigFromEnv()

	pub, err := aws.NewPublisher(cfg)
	if err != nil {
		pubsub.Log.WithFields(logrus.Fields{
			"error": err,
		}).Fatal("unable to init publisher")
	}

	catArticle := &nyt.SemanticConceptArticle{
		Title:  "It's a Cat World",
		Byline: "By JP Robinson",
		Url:    "http://www.nytimes.com/2015/11/25/its-a-cat-world",
	}

	err = pub.Publish(nil, catArticle.Url, catArticle)
	if err != nil {
		pubsub.Log.WithFields(logrus.Fields{
			"error": err,
		}).Fatal("unable to publish message")
	}

	pubsub.Log.WithFields(logrus.Fields{
		"articles": catArticle,
	}).Info("successfully published cat article")
}
예제 #2
0
파일: config.go 프로젝트: ycaihua/gizmo
// LoadConfigFromEnv will attempt to inspect the environment
// of any valid config options and will return a populated
// Config struct with what it found.
// If you need a unique config object and want to use envconfig, you
// will need to run the LoadXXFromEnv for each child struct in
// your config struct. For an example on how to do this, check out the
// guts of this function.
func LoadConfigFromEnv() *Config {
	var app Config
	config.LoadEnvConfig(&app)
	app.AWS = aws.LoadConfigFromEnv()
	app.SNS = awsps.LoadSNSConfigFromEnv()
	app.SQS = awsps.LoadSQSConfigFromEnv()
	app.S3 = aws.LoadS3FromEnv()
	app.DynamoDB = aws.LoadDynamoDBFromEnv()
	app.ElastiCache = aws.LoadElastiCacheFromEnv()
	app.MongoDB = mongodb.LoadConfigFromEnv()
	app.Kafka = kafka.LoadConfigFromEnv()
	app.MySQL = mysql.LoadConfigFromEnv()
	app.Oracle = oracle.LoadConfigFromEnv()
	app.Cookie = cookie.LoadConfigFromEnv()
	app.Server = server.LoadConfigFromEnv()
	app.Metrics = metrics.LoadConfigFromEnv()
	return &app
}