Giter Club home page Giter Club logo

go-channels-monitor's Introduction

go-channels-monitor

go-channels-monitor is a utility and service for keeping track of channel capacities and reporting on them.

##Install

$ go get github.com/longshotsyndicate/go-channels-monitor

##Usage

  boolChannel := make(chan bool, 100)
  
  // add your channel to be monitored, optionally specifying a string instance id for the channel.
  //in this example we are registering one of potentially many boolChannel channels, each with an id like "instance-10"
  //instances need to be unique for the channel name but not globally unique. 
  monitor.AddNamed("bool-channel-name", "instance-"+strconv.Itoa(nLogWriters++), boolChannel)
  
  properties := monitor.Get("bool-channel-name", "instance-1")
  
  log.Printf("bool-channel-name len: %d, cap: %d, instance: %s", properties.Len, properties.Cap, properties.Instance)
  

Service

The service type allows you to query for channel properties.

  
  //async error reporting
  errc := make(chan error)
  go func() {
    for _, err := range errc {
      log.Printf("Error: %v", err)
    }
  }()
  
  //create and start the service that responds with channel properties.
  service.New("my-service", ":9999", errc).Start()
  

###Query Response Making a GET request on your-ip:9999/channels will result in the following reponse:

{"service":"bool-channel-name",
  "channels":{
    "foo":{"length":0,"capacity":100, "instance": "instance-1"}
  }
}

go-channels-monitor's People

Contributors

dprime 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.