forked from nytimes/gizmo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
36 lines (30 loc) · 824 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"github.com/NYTimes/gizmo/config"
"github.com/NYTimes/gizmo/examples/nyt"
"github.com/NYTimes/gizmo/pubsub"
"github.com/Sirupsen/logrus"
)
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")
}