metronome

package module
v0.0.0-...-d990f74 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2015 License: MIT Imports: 13 Imported by: 0

README

Metronome

A quick and dirty hack to retrieve server stats and shared them via websockets. Contains a server and a client.

Steps

  1. Install dependencies via make deps
  2. Compile via make build
  3. Copy ./metronomed.example.toml to ./metronomed.toml and modify accordingly.
  4. Run ./metronomed in console 1
  5. Run ./metronome in console 2

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuth

func BasicAuth(r *http.Request) (username, password string, err error)

BasicAuth parses the Authorization header of the request. If absent or invalid, an error is returned.

Types

type Client

type Client struct {

	// Connected is used to indicate a successful connection.
	Connected chan bool

	// Disconnected is used to indicate a server disconnect.
	Disconnected chan bool

	// Incoming has messages sent from server to client.
	Incoming chan []byte
	// contains filtered or unexported fields
}

Client connects to a server via Websockets.

func NewClient

func NewClient(addr, username, password string) (*Client, error)

NewClient returns a client that connects to a server via Websockets.

type Server

type Server struct {
	Addr               string
	Username, Password string
	Logger             *log.Logger
	// contains filtered or unexported fields
}

Server gathers information via plugins and sends it to registered clients via websockets.

func NewServer

func NewServer() *Server

NewServer creates a new Metronome server. Use Start to start it up.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles HTTP requests.

func (*Server) Start

func (s *Server) Start()

Start starts the server.

func (*Server) UpdateInterval

func (s *Server) UpdateInterval(interval time.Duration) *Server

UpdateInterval specifies the time between two snapshots.

type Status

type Status struct {
	// Metrics data.
	Metrics map[string]interface{} `json:"metrics"`
}

Status is a status update sent to registered clients.

Directories

Path Synopsis
cmd
mem

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL