drain

package
v3.6.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2014 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DRAINS = map[string]DrainConstructor{
	"redis": NewRedisDrain,
	"tcp":   NewIPConnDrain,
	"udp":   NewIPConnDrain,
	"file":  NewFileDrain,
}

DRAINS is a map of drain type (string) to its constructur function

Functions

func ConstructDrainURI

func ConstructDrainURI(
	name, uri string, filters []string, params map[string]string) (string, error)

ConstructDrainURI constructs the drain URI from given parameters.

func NewRetryerForDrain

func NewRetryerForDrain(name string) retry.Retryer

NewRetryerForDrain chooses

Types

type DrainConfig

type DrainConfig struct {
	Name    string
	Type    string
	Scheme  string
	Host    string // host+port part of the uri (optional in some drains)
	Path    string
	Filters []string           // Filter messages by these keys.
	Format  *template.Template // Format message json using Go's
	// template library; if
	// format==raw, send the raw
	// stream: "<key> <msg>"
	Params map[string]string // Params specific to that drain type.
	// contains filtered or unexported fields
}

func ParseDrainUri

func ParseDrainUri(name string, uri string, namedFormats map[string]string) (*DrainConfig, error)

ParseDrainUri creates a DrainConfig from the drain URI.

func (*DrainConfig) FormatJSON

func (c *DrainConfig) FormatJSON(msg zmqpubsub.Message) ([]byte, error)

FormatJSON formats the given message and returns it with a newline

func (*DrainConfig) GetParam

func (c *DrainConfig) GetParam(key string, def string) string

GetParam returns the corresponding param; else the default value (def)

func (*DrainConfig) GetParamBool

func (c *DrainConfig) GetParamBool(key string, def bool) (bool, error)

func (*DrainConfig) GetParamInt

func (c *DrainConfig) GetParamInt(key string, def int) (int, error)

type DrainConstructor

type DrainConstructor func(string) DrainType

DrainConstructor is a function that returns a new drain instance

type DrainManager

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

func NewDrainManager

func NewDrainManager() *DrainManager

func (*DrainManager) Run

func (manager *DrainManager) Run()

func (*DrainManager) StartDrain

func (manager *DrainManager) StartDrain(name, uri string, retry retry.Retryer)

func (*DrainManager) Stop

func (manager *DrainManager) Stop()

Stop stops the drain manager including running drains

func (*DrainManager) StopDrain

func (manager *DrainManager) StopDrain(drainName string, clearStateCache bool)

type DrainProcess

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

func NewDrainProcess

func NewDrainProcess(name, uri string) (*DrainProcess, error)

func (*DrainProcess) Logf

func (p *DrainProcess) Logf(msg string, v ...interface{}) string

func (*DrainProcess) Start

func (p *DrainProcess) Start() error

func (*DrainProcess) Stop

func (p *DrainProcess) Stop() error

func (*DrainProcess) String

func (p *DrainProcess) String() string

func (*DrainProcess) Wait

func (p *DrainProcess) Wait() error

func (*DrainProcess) WaitRunning

func (p *DrainProcess) WaitRunning() bool

WaitRunning waits until the drain is running

type DrainType

type DrainType interface {
	// Start starts the drain, and returns immediately without
	// blocking.
	Start(*DrainConfig)
	Stop() error
	Wait() error
	WaitRunning() bool
}

func NewFileDrain

func NewFileDrain(name string) DrainType

func NewIPConnDrain

func NewIPConnDrain(name string) DrainType

func NewRedisDrain

func NewRedisDrain(name string) DrainType

type FileDrain

type FileDrain struct {
	tomb.Tomb
	// contains filtered or unexported fields
}

File drain is used to write to local files

func (*FileDrain) Start

func (d *FileDrain) Start(config *DrainConfig)

func (*FileDrain) Stop

func (d *FileDrain) Stop() error

func (*FileDrain) WaitRunning

func (d *FileDrain) WaitRunning() bool

type IPConnDrain

type IPConnDrain struct {
	tomb.Tomb
	// contains filtered or unexported fields
}

IPConnDrain is a drain based on net.IPConn

func (*IPConnDrain) Start

func (d *IPConnDrain) Start(config *DrainConfig)

func (*IPConnDrain) Stop

func (d *IPConnDrain) Stop() error

func (*IPConnDrain) WaitRunning

func (d *IPConnDrain) WaitRunning() bool

type NetDialer

type NetDialer struct {
	Ch    chan net.Conn
	Error error
}

NetDialer provides a channel-friendly wrapper for net.DialTimeout so that it can be used along with `select{}`.

func NewNetDialer

func NewNetDialer(scheme, host string, timeout time.Duration) *NetDialer

func (*NetDialer) WaitAndClose

func (d *NetDialer) WaitAndClose()

WaitAndClose waits for the connection to return and closes it immediately.

type RedisDrain

type RedisDrain struct {
	tomb.Tomb
	// contains filtered or unexported fields
}

func (*RedisDrain) Lpushcircular

func (d *RedisDrain) Lpushcircular(
	key string, item string, maxlen int64) (int64, error)

Lpushcircular works like LPUSH, but trims the right most element if length exceeds maxlen. Returns the list length before trim.

func (*RedisDrain) Start

func (d *RedisDrain) Start(config *DrainConfig)

func (*RedisDrain) Stop

func (d *RedisDrain) Stop() error

func (*RedisDrain) WaitRunning

func (d *RedisDrain) WaitRunning() bool

Jump to

Keyboard shortcuts

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