forked from crosbymichael/hooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
archive.go
31 lines (28 loc) · 819 Bytes
/
archive.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
package main
import (
"github.com/bitly/go-nsq"
"github.com/codegangsta/cli"
"github.com/crosbymichael/hooks/workers"
)
var archiveCommand = cli.Command{
Name: "archive",
Usage: "archive hooks into a rethinkdb for processing",
Action: archiveAction,
}
func archiveAction(context *cli.Context) {
session, err := NewRethinkdbSession()
if err != nil {
logger.Fatal(err)
}
defer session.Close()
producer, err := nsq.NewProducer(config.NSQD, nsq.NewConfig())
if err != nil {
logger.Fatal(err)
}
defer producer.Stop()
handler := workers.NewArchiveWorker(session, config.Archive.ArchiveTable,
config.Archive.SubscribersTable, config.Archive.BroadcastTopic, producer)
if err := ProcessQueue(handler, QueueOptsFromContext(config.Archive.HooksTopic, "archive")); err != nil {
logger.Fatal(err)
}
}