dashing

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

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

Go to latest
Published: Feb 18, 2016 License: MIT Imports: 9 Imported by: 4

README

dashing-go

A Go port of shopify/dashing. Now frameworkless!

To generate a dashboard using this library, please use the Yeoman dashing-go generator.

For a live demo, here's the default sample dashboard.

Current Status
  • All endpoints have been ported over! Full functionality is available.
  • For an example of how to write jobs in dashing-go, please refer to the demo dashboard source.

Credits

Much of the code is referenced from golang-sse-todo by @rwynn.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(j Job)

Register a job to be kicked off upon starting a worker.

Types

type Broker

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

A Broker broadcasts events to multiple clients.

func NewBroker

func NewBroker() *Broker

NewBroker creates a Broker instance.

func (*Broker) Start

func (b *Broker) Start()

Start managing client connections and event broadcasts.

type Dashing

type Dashing struct {
	Broker *Broker
	Worker *Worker
	Server *Server
	Router http.Handler
	// contains filtered or unexported fields
}

Dashing struct definition.

func NewDashing

func NewDashing() *Dashing

NewDashing sets up the event broker, workers and webservice.

func (*Dashing) ServeHTTP

func (d *Dashing) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the HTTP Handler.

func (*Dashing) Start

func (d *Dashing) Start() *Dashing

Start actives the broker and workers.

type Event

type Event struct {
	ID     string
	Body   map[string]interface{}
	Target string
}

An Event contains the widget ID, a body of data, and an optional target (only "dashboard" for now).

type Job

type Job interface {
	Work(send chan *Event)
}

A Job does periodic work and sends events to a channel.

type Server

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

A Server contains webservice parameters and middlewares.

func NewServer

func NewServer(b *Broker) *Server

NewServer creates a Server instance.

func (*Server) DashboardEventHandler

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

DashboardEventHandler accepts dashboard events.

func (*Server) DashboardHandler

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

DashboardHandler serves the dashboard layout template.

func (*Server) EventsHandler

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

EventsHandler opens a keepalive connection and pushes events to the client.

func (*Server) IndexHandler

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

IndexHandler redirects to the default dashboard.

func (*Server) NewRouter

func (s *Server) NewRouter() http.Handler

NewRouter creates a router with defaults.

func (*Server) WidgetEventHandler

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

WidgetEventHandler accepts widget data.

func (*Server) WidgetHandler

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

WidgetHandler serves widget templates.

type Worker

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

A Worker contains a collection of jobs.

func NewWorker

func NewWorker(b *Broker) *Worker

NewWorker returns a Worker instance.

func (*Worker) Register

func (w *Worker) Register(j Job)

Register a job for a particular worker.

func (*Worker) Start

func (w *Worker) Start()

Start all jobs.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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