sieve

package module
v0.0.0-...-01ecdc4 Latest Latest
Warning

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

Go to latest
Published: May 1, 2014 License: MIT Imports: 11 Imported by: 0

README

sieve Project status

A command line utility for graphing piped data. Sieve is used when you have data output from one program and you need to quickly and interactively inspect it without needing the full power of gnuplot.

Usage

To install sieve, simply run:

$ go install github.com/benbjohnson/sieve/...

Then run it from the command line:

$ cat mydata.json | sieve
Listening on http://localhost:6900

Open http://localhost:6900 in your browser and you'll see the data that was piped from mydata.json.

Example

To see sieve in action you can use the random walk generator bundled with sieve:

$ sievegen | sieve

Then open http://localhost:6900 in your browser can watch the random walk.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func NewHandler

func NewHandler(db *DB) http.Handler

NewHandler returns a new root web handler.

Types

type AssetsHandler

type AssetsHandler struct{}

AssetsHandler handles HTTP requests for static files.

func (*AssetsHandler) ServeHTTP

func (h *AssetsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP sends the requested asset file.

type DB

type DB struct {
	sync.Mutex
	Rows []*Row
	// contains filtered or unexported fields
}

DB represents a simple in-memory database. It stores data in FIFO order so that data can be retrieved by index.

func NewDB

func NewDB() *DB

NewDB returns a new instance of a database.

func (*DB) Append

func (db *DB) Append(row *Row)

Append adds a row to the database.

func (*DB) Length

func (db *DB) Length() int

Length returns the number of rows.

func (*DB) Row

func (db *DB) Row(index int) *Row

Row returns a row at a given index.

func (*DB) Subscribe

func (db *DB) Subscribe(index int) chan *Row

Subscribe returns a channel that pipes all rows since a given index.

func (*DB) Unsubscribe

func (db *DB) Unsubscribe(ch chan *Row)

Unsubscribe removes a channel as a subscriber.

type IndexHandler

type IndexHandler struct{}

IndexHandler returns the main index page.

func (*IndexHandler) ServeHTTP

func (h *IndexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP sends the index page to the client.

type Row

type Row struct {
	Data map[string]interface{}
	// contains filtered or unexported fields
}

Row represents a single element in the database.

func (*Row) Index

func (r *Row) Index() int

Index returns the row index in the database.

func (*Row) MarshalJSON

func (r *Row) MarshalJSON() ([]byte, error)

MarshalJSON encodes a row into a JSON structure.

func (*Row) Timestamp

func (r *Row) Timestamp() time.Time

Timestamp returns the row's creation timestamp.

type SubscribeHandler

type SubscribeHandler struct {
	// contains filtered or unexported fields
}

SubscribeHandler sends data to the client via server sent events.

func NewSubscribeHandler

func NewSubscribeHandler(db *DB) *SubscribeHandler

NewSubscribeHandler returns a new subscription handler for a database.

func (*SubscribeHandler) ServeHTTP

func (h *SubscribeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP sends the database data.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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