- install nsq
- go get github.com/mayur-tolexo/drift
- cd $GOPATH/src/github.com/mayur-tolexo/drift
- install godep
- godep restore
- go run example/drift.go
[in new tab]
cd $GOPATH/src/github.com/mayur-tolexo/drift- go run nsqlookup/nsqlookup.go
[in new tab]
cd $GOPATH/src/github.com/mayur-tolexo/drift- go run nsqd/nsqd.go --lookupd-tcp-address=127.0.0.1:4160
[in new tab]
cd $GOPATH/src/github.com/mayur-tolexo/drift- go run example/producer.go
- add new consumer as mention below
- start admin as mention below
- open http://127.0.0.1:4171/ in browser
POST localhost:1500/drift/v1/start/admin/
{
"lookup_http_address": ["127.0.0.1:4161"],
"http_address":"localhost:4171",
"user": ["drift-user"],
"acl_http_header": "admin-user"
}
GET localhost:1500/drift/v1/stop/admin/
POST localhost:1500/drift/v1/add/consumer/
{
"lookup_http_address": [
"127.0.0.1:4161"
],
"topic_detail": [
{
"topic": "elastic",
"channel": "v2.1",
"count": 1
},
{
"topic": "elastic",
"channel": "v6.2",
"count": 2
}
],
"max_in_flight": 200
}
GET localhost:1500/drift/v1/consumer/?topic=elastic&channel=v2.1
GET localhost:1500/drift/v1/consumer/?topic=elastic
POST localhost:1500/drift/v1/kill/consumer/
{
"topic": "elastic",
"channel": "v2.1",
"count":1
}
POST localhost:1500/drift/v1/pub/request/
{
"nsqd_tcp_address": ["127.0.0.1:4150"],
"topic": "elastic",
"data": "This is a test over http"
}
//printIT : function which consumer will call to execute
func printIT(value ...interface{}) error {
fmt.Println(value)
return nil
}
func main() {
d := drift.NewConsumer(printIT)
d.Start(1500)
}
handler is a function to which the consumer will call.
FUNCTION DEFINATION:
func(value ...interface{}) error
Here PrintIT is a handler function. Define your own handler and pass it in the drift and you are ready to go.