Skip to content

Expose channel capacities and current fill via a http/json endpoint.

License

Notifications You must be signed in to change notification settings

longshotsyndicate/go-channels-monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Expose channel capacities and current fill via a http/json endpoint.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages