Giter Club home page Giter Club logo

drift's Introduction

Godocs Go Report Card Open Source Helpers Release

# drift NSQ Producer/Consumer integration to drift your request smoothly. Add/Kill consumer over http request on any topic. Publish new request over http on any nsqd.

STEPS TO RUN drift

  1. install nsq
  2. go get github.com/mayur-tolexo/drift
  3. cd $GOPATH/src/github.com/mayur-tolexo/drift
  4. install godep
  5. godep restore
  6. go run example/drift.go
  7. [in new tab] cd $GOPATH/src/github.com/mayur-tolexo/drift
  8. go run nsqlookup/nsqlookup.go
  9. [in new tab] cd $GOPATH/src/github.com/mayur-tolexo/drift
  10. go run nsqd/nsqd.go --lookupd-tcp-address=127.0.0.1:4160
  11. [in new tab] cd $GOPATH/src/github.com/mayur-tolexo/drift
  12. go run example/producer.go
  13. add new consumer as mention below
  14. start admin as mention below
  15. open http://127.0.0.1:4171/ in browser

START ADMIN

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"
}

STOP ADMIN

GET localhost:1500/drift/v1/stop/admin/

ADD NEW CONSUMER

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
}

COUNT CONSUMERS OF A TOPIC ON SPECIFIC CHANNEL

GET localhost:1500/drift/v1/consumer/?topic=elastic&channel=v2.1

COUNT ALL CONSUMERS OF A TOPIC

GET localhost:1500/drift/v1/consumer/?topic=elastic

KILL CONSUMER

POST localhost:1500/drift/v1/kill/consumer/

{
  "topic": "elastic",
  "channel": "v2.1",
  "count":1
}

PUBLISH REQUEST

POST localhost:1500/drift/v1/pub/request/

{
  "nsqd_tcp_address": ["127.0.0.1:4150"],
  "topic": "elastic",
  "data": "This is a test over http"
}

Example

//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

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.

drift's People

Contributors

mayur-tolexo avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.