Exemplo n.º 1
0
// heartBeat periodically sends a heartbeat message.
func heartBeat() {
	inter := time.Duration(15) * time.Second

	for {
		h := &hb{msg.Haz{HeartBeat: &msg.HeartBeat{ServiceID: heartBeatId, SentTime: time.Now().UTC()}}}
		msg.Process(h)
		time.Sleep(inter)
	}
}
Exemplo n.º 2
0
// listen listens to the SQS queue for intensity messages and saves them to the DB.
func listen() {
	rx, dx, err := sqs.InitRx()
	if err != nil {
		log.Fatalf("ERROR - problem creating SQS from config: %s", err)
	}

	for {
		r := <-rx
		m := message{}
		m.Decode([]byte(r.Body))
		if !msg.Process(&m) {
			dx <- r.ReceiptHandle
		}
	}
}
Exemplo n.º 3
0
func main() {
	rx, dx, err := sqs.InitRx()
	if err != nil {
		log.Fatalf("ERROR - problem creating SQS from config: %s", err)
	}

	log.Print("starting message listner")

	for {
		r := <-rx
		h := message{}
		h.Decode([]byte(r.Body))
		if !msg.Process(&h) {
			dx <- r.ReceiptHandle
		}
	}
}
Exemplo n.º 4
0
// sc3ml polls the spool dir for SeisComPML files and runs Process on them.
func sc3ml() {
	inter := time.Duration(1) * time.Second

	for {
		files, err := ioutil.ReadDir(sc3SpoolDir)
		if err != nil {
			log.Printf("WARN: %s", err.Error())
		}

		for _, fi := range files {
			if strings.HasSuffix(fi.Name(), ".xml") {
				s := &sc3{f: fi.Name()}
				if !msg.Process(s) {
					if err := os.Remove(sc3SpoolDir + "/" + s.f); err != nil {
						log.Println(err)
					}
				}
			}
		}

		time.Sleep(inter)
	}
}
Exemplo n.º 5
0
func main() {
	rx, dx, err := sqs.InitRx()
	if err != nil {
		log.Fatalf("ERROR - problem creating SQS from config: %s", err)
	}

	ttr, err = twitter.Init()
	if err != nil {
		log.Fatalf("ERROR: Twitter init error: %s", err.Error())
	}

	log.Printf("Twitter magnitude threshold %.1f", threshold)

	log.Print("starting message listner")

	for {
		r := <-rx
		h := message{}
		h.Decode([]byte(r.Body))
		if !msg.Process(&h) {
			dx <- r.ReceiptHandle
		}
	}
}