writers

package
v3.1.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2016 License: MIT Imports: 19 Imported by: 2

Documentation

Overview

Package writers provides objects that can send colected resource data to external place.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, constructor func() IWriter)

Register makes any writer constructor available by name.

Types

type AgentResourcePayload

type AgentResourcePayload struct {
	Data map[string]interface{}
	Host map[string]interface{}
}

type Base

type Base struct {
	Configs       *resourced_config.Configs
	ReadersData   map[string]interface{}
	Data          interface{}
	JsonProcessor string
}

func (*Base) GenerateData added in v1.4.0

func (b *Base) GenerateData() error

GenerateData pulls ReadersData field and set it to Data field. If JsonProcessor is defined, use it to mangle JSON and save the new JSON on Data field.

func (*Base) GetData added in v1.4.0

func (b *Base) GetData() interface{}

GetData returns Data field.

func (*Base) GetJsonProcessor

func (b *Base) GetJsonProcessor() string

GetJsonProcessor returns json processor path.

func (*Base) GetReadersData

func (b *Base) GetReadersData() map[string]interface{}

GetReadersData returns ReadersData field.

func (*Base) Run

func (b *Base) Run() error

Run executes the writer.

func (*Base) SetConfigs

func (b *Base) SetConfigs(configs *resourced_config.Configs)

SetConfigs remembers configs data in-memory.

func (*Base) SetData added in v1.4.0

func (b *Base) SetData(data interface{})

SetData assigns Data field.

func (*Base) SetReadersData

func (b *Base) SetReadersData(readersData map[string]interface{})

SetReadersData assigns ReadersData field.

func (*Base) SetReadersDataInBytes

func (b *Base) SetReadersDataInBytes(readersJsonBytes map[string][]byte)

SetReadersDataInBytes pulls readers data and store them on ReadersData field.

func (*Base) ToJson

func (b *Base) ToJson() ([]byte, error)

ToJson serialize Data field to JSON.

func (*Base) WatchDir

func (b *Base) WatchDir(path string, callback func() error) error

WatchDir watches a directory and execute callback on any changes.

type Graphite

type Graphite struct {
	Base
	Addr       string
	Protocol   string
	Prefix     string
	MaxRetries int64
}

Graphite is a writer that simply serialize all readers data to Graphite.

func (*Graphite) Run

func (g *Graphite) Run() error

Run executes the writer.

type Http

type Http struct {
	Base
	Url        string
	Method     string
	Headers    string
	Username   string
	Password   string
	MaxRetries int64
}

Http is a writer that simply serialize all readers data to Http.

func (*Http) NewHttpRequest

func (h *Http) NewHttpRequest(dataJson []byte) (*http.Request, error)

NewHttpRequest builds and returns http.Request struct.

func (*Http) Run

func (h *Http) Run() error

Run executes the writer.

type IWriter

type IWriter interface {
	WatchDir(string, func() error) error
	Run() error
	SetConfigs(*resourced_config.Configs)
	SetReadersDataInBytes(map[string][]byte)
	SetReadersData(map[string]interface{})
	GetReadersData() map[string]interface{}
	SetData(interface{})
	GetData() interface{}
	GetJsonProcessor() string
	GenerateData() error
	ToJson() ([]byte, error)
}

IWriter is general interface for writer.

func NewGoStruct

func NewGoStruct(name string) (IWriter, error)

NewGoStruct instantiates IWriter

func NewGoStructByConfig

func NewGoStructByConfig(config resourced_config.Config) (IWriter, error)

NewGoStructByConfig instantiates IWriter given Config struct

func NewGraphite

func NewGraphite() IWriter

NewGraphite is Graphite constructor.

func NewHttp

func NewHttp() IWriter

NewHttp is Http constructor.

func NewNewrelicInsights added in v1.3.0

func NewNewrelicInsights() IWriter

NewNewrelicInsights is NewrelicInsights constructor.

func NewResourcedMasterHost

func NewResourcedMasterHost() IWriter

NewResourcedMasterHost is ResourcedMasterHost constructor.

func NewShell

func NewShell() IWriter

func NewStdOut

func NewStdOut() IWriter

NewStdOut is StdOut constructor.

type NewrelicInsights added in v1.3.0

type NewrelicInsights struct {
	Http
	EventType string
}

NewrelicInsights is a writer that serialize readers data to New Relic Insights.

func (*NewrelicInsights) Run added in v1.4.0

func (nr *NewrelicInsights) Run() error

Run executes the writer.

func (*NewrelicInsights) ToJson added in v1.3.0

func (nr *NewrelicInsights) ToJson() ([]byte, error)

ToJson serialize Data field to JSON.

type ResourcedMasterHost

type ResourcedMasterHost struct {
	Http
}

ResourcedMasterHost is a writer that serialize readers data to ResourcedMasterHost.

func (*ResourcedMasterHost) Run

func (rmh *ResourcedMasterHost) Run() error

Run executes the writer.

type Shell

type Shell struct {
	Base
	Command string
	Data    map[string]interface{}
}

func (*Shell) Run

func (s *Shell) Run() error

Run shells out external program and store the output on c.Data.

func (*Shell) ToJson

func (s *Shell) ToJson() ([]byte, error)

ToJson serialize Data field to JSON.

type StdOut

type StdOut struct {
	Base
}

StdOut is a writer that simply serialize all readers data to STDOUT.

func (*StdOut) Run

func (s *StdOut) Run() error

Run puts all readers data to STDOUT.

Jump to

Keyboard shortcuts

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