Esempio n. 1
0
File: main.go Progetto: strogo/gizmo
func main() {
	cfg := config.LoadConfigFromEnv()

	pub, err := pubsub.NewSNSPublisher(cfg.SNS)
	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(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")
}
Esempio n. 2
0
// NewJSONPubService will instantiate a JSONPubService
// with the given configuration.
func NewJSONPubService(cfg *config.Config) *JSONPubService {
	pub, err := pubsub.NewSNSPublisher(cfg.SNS)
	if err != nil {
		server.Log.Fatal("unable to init publisher: ", err)
	}
	return &JSONPubService{pub}
}