raidman

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

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

Go to latest
Published: Jul 7, 2017 License: Unlicense Imports: 15 Imported by: 0

README

Raidman

Go Riemann client

package main

import (
        "github.com/amir/raidman"
)

func main() {
        c, err := raidman.Dial("tcp", "localhost:5555")
        if err != nil {
                panic(err)
        }

        var event = &raidman.Event{
                State:   "success",
                Host:    "raidman",
                Service: "raidman-sample",
                Metric:  100,
                Ttl:     10,
        }

        // send one event
        err = c.Send(event)
        if err != nil {
                panic(err)
        }
        
        // send multiple events at once
        err = c.SendMulti([]*raidman.Event{
                &raidman.Event{
                        State:   "success",
                        Host:    "raidman",
                        Service: "raidman-sample",
                        Metric:  100,
                        Ttl:     10,
                },
                &raidman.Event{
                        State:   "failure",
                        Host:    "raidman",
                        Service: "raidman-sample",
                        Metric:  100,
                        Ttl:     10,
                },
                &raidman.Event{
                        State:   "success",
                        Host:    "raidman",
                        Service: "raidman-sample",
                        Metric:  100,
                        Ttl:     10,
                },
        })
        if err != nil {
                panic(err)
        }

        events, err := c.Query("host = \"raidman\"")
        if err != nil {
                panic(err)
        }

        if len(events) < 1 {
                panic("Submitted event not found")
        }

        c.Close()
}

Documentation

Overview

Go Riemann client

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Client represents a connection to a Riemann server

func Dial

func Dial(netwrk, addr string) (c *Client, err error)

Dial establishes a connection to a Riemann server at addr, on the network netwrk.

Known networks are "tcp", "tcp4", "tcp6", "udp", "udp4", and "udp6".

func DialWithTimeout

func DialWithTimeout(netwrk, addr string, timeout time.Duration) (c *Client, err error)

Dial establishes a connection to a Riemann server at addr, on the network netwrk, with a timeout of timeout

Known networks are "tcp", "tcp4", "tcp6", "udp", "udp4", and "udp6".

func (*Client) Close

func (c *Client) Close()

Close closes the connection to Riemann

func (*Client) Query

func (c *Client) Query(q string) ([]Event, error)

Query returns a list of events matched by query

func (*Client) Send

func (c *Client) Send(event *Event) error

Send sends an event to Riemann

func (*Client) SendMulti

func (c *Client) SendMulti(events []*Event) error

SendMulti sends multiple events to Riemann

type ClientBuilder

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

the

func NewClientBuilder

func NewClientBuilder() *ClientBuilder

func (*ClientBuilder) Build

func (builder *ClientBuilder) Build() (c *Client, err error)

func (*ClientBuilder) WithAddress

func (builder *ClientBuilder) WithAddress(addr string) *ClientBuilder

func (*ClientBuilder) WithDialer

func (builder *ClientBuilder) WithDialer(dialer Dialer) *ClientBuilder

func (*ClientBuilder) WithEnvironmentProxy

func (builder *ClientBuilder) WithEnvironmentProxy() *ClientBuilder

func (*ClientBuilder) WithNetwork

func (builder *ClientBuilder) WithNetwork(network string) *ClientBuilder

func (*ClientBuilder) WithTimeout

func (builder *ClientBuilder) WithTimeout(duration time.Duration) *ClientBuilder

type CnxnBuilder

type CnxnBuilder interface {
	WithDialer(dialer Dialer) *CnxnBuilder
	WithEnvironmentProxy(use bool) *CnxnBuilder
	WithNetwork(network string) *CnxnBuilder
	WithTimeout(duration time.Duration) *CnxnBuilder
	Build() (*Client, error)
}

ClientBuilder uses the builder pattern to create Clients with different options

type Dialer

type Dialer interface {
	// Dial connects to the given address via the proxy.
	Dial(network, addr string) (c net.Conn, err error)
}

A Dialer is a means to establish a connection.

type Event

type Event struct {
	Ttl         float32
	Time        int64
	Tags        []string
	Host        string // Defaults to os.Hostname()
	State       string
	Service     string
	Metric      interface{} // Could be Int, Float32, Float64
	Description string
	Attributes  map[string]string
}

An Event represents a single Riemann event

func (*Event) Equals

func (e *Event) Equals(e1 *Event) (bool, error)

this is generally for tests

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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