stdoutpublisher

package
v0.0.0-...-b9af62b Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2017 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Publisher

type Publisher struct{}

Publisher implements canary.Publisher, and is our gateway for delivering canary.Measurement data to STDOUT.

func New

func New() *Publisher

New returns a pointer to a new Publsher.

func (*Publisher) Publish

func (p *Publisher) Publish(m sensor.Measurement) (err error)

Publish takes a canary.Measurement and emits data to STDOUT.

Example
url, _ := sampler.NewJsonURL("http://www.canary.io")
target := sampler.Target{
	URL: *url,
}

t1, _ := time.Parse(time.RFC3339, "2014-12-28T00:00:00Z")
t2, _ := time.Parse(time.RFC3339, "2014-12-28T00:00:01Z")

sample := sampler.Sample{
	TimeStart:  t1,
	TimeEnd:    t2,
	StatusCode: 200,
}

p := New()
p.Publish(sensor.Measurement{
	Target:     target,
	Sample:     sample,
	IsOK:       true,
	StateCount: 2,
})
Output:

2014-12-28T00:00:01Z http://www.canary.io 200 1000.000000 true 2

Jump to

Keyboard shortcuts

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