canary: github.com/canaryio/canary/pkg/stdoutpublisher Index | Examples | Files

package stdoutpublisher

import "github.com/canaryio/canary/pkg/stdoutpublisher"

Index

Examples

Package Files

publisher.go

type Publisher Uses

type Publisher struct{}

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

func New Uses

func New() *Publisher

New returns a pointer to a new Publsher.

func (*Publisher) Publish Uses

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

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

Code:

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

Package stdoutpublisher imports 3 packages (graph). Updated 2016-08-01. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).