hydra

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2014 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFluentdPort       = 24224
	DefaultFieldName         = "message"
	DefaultMaxBufferMessages = 1024 * 1024
)
View Source
const (
	OpenRetryInterval = 1 * time.Second
	SEEK_TAIL         = int64(-1)
	SEEK_HEAD         = int64(0)
	DEBUG             = false
)
View Source
const (
	MessageChannelBufferLen = 1
	MonitorChannelBufferLen = 256
)
View Source
const (
	DefaultMonitorPort = 24223
	DefaultMonitorHost = "localhost"
)
View Source
const (
	FlashInterval = 200 * time.Millisecond
)
View Source
const (
	TailInterval = 200 * time.Millisecond
)

Variables

View Source
var (
	LineSeparator = []byte{'\n'}
)
View Source
var (
	ReadBufferSize = 64 * 1024
)

Functions

func NewChannel

func NewChannel() (chan *fluent.FluentRecordSet, chan Stat)

NewChannel create channel for using by OutForward() and InTail().

func NewFluentRecordSet

func NewFluentRecordSet(tag string, key string, buffer *[]byte) *fluent.FluentRecordSet

func Rel2Abs

func Rel2Abs(filename string) (string, error)

Types

type Config

type Config struct {
	TagPrefix      string
	FieldName      string
	ReadBufferSize int
	Servers        []*ConfigServer
	Logs           []*ConfigLogfile
	Receiver       *ConfigReceiver
	Monitor        *ConfigMonitor
}

func NewConfigByArgs

func NewConfigByArgs(args []string, fieldName string, monitorAddr string) *Config

func ReadConfig

func ReadConfig(filename string) (*Config, error)

func (*Config) Restrict

func (c *Config) Restrict()

type ConfigLogfile

type ConfigLogfile struct {
	Tag       string
	File      string
	FieldName string
}

func (*ConfigLogfile) Restrict

func (cl *ConfigLogfile) Restrict(c *Config)

type ConfigMonitor added in v0.0.4

type ConfigMonitor struct {
	Host string
	Port int
}

func (*ConfigMonitor) Restrict added in v0.0.4

func (cr *ConfigMonitor) Restrict(c *Config)

type ConfigReceiver

type ConfigReceiver struct {
	Host              string
	Port              int
	MaxBufferMessages int
}

func (*ConfigReceiver) Restrict

func (cr *ConfigReceiver) Restrict(c *Config)

type ConfigServer

type ConfigServer struct {
	Host string
	Port int
}

func (*ConfigServer) Address

func (cs *ConfigServer) Address() string

func (*ConfigServer) Restrict

func (cs *ConfigServer) Restrict(c *Config)

type File

type File struct {
	*os.File
	Path     string
	Tag      string
	Position int64

	FieldName string
	// contains filtered or unexported fields
}

func (*File) NewStat

func (f *File) NewStat() *FileStat

type FileStat

type FileStat struct {
	Tag      string `json:"tag"`
	File     string `json:"-"`
	Position int64  `json:"position"`
	Error    string `json:"error"`
}

func (*FileStat) ApplyTo

func (s *FileStat) ApplyTo(ss *Stats)

type InForward

type InForward struct {
	Addr net.Addr
	// contains filtered or unexported fields
}

func NewInForward

func NewInForward(config *ConfigReceiver, messageCh chan *fluent.FluentRecordSet, monitorCh chan Stat) (*InForward, error)

func (*InForward) Run

func (f *InForward) Run()

type InTail

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

func NewInTail

func NewInTail(config *ConfigLogfile, watcher *Watcher, messageCh chan *fluent.FluentRecordSet, monitorCh chan Stat) (*InTail, error)

func (*InTail) Run

func (t *InTail) Run()

InTail follow the tail of file and post BulkMessage to channel.

type MessageQueue

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

func NewMessageQueue

func NewMessageQueue(maxMessages int) *MessageQueue

func (*MessageQueue) Dequeue

func (q *MessageQueue) Dequeue() (*fluent.FluentRecordSet, bool)

func (*MessageQueue) Enqueue

func (q *MessageQueue) Enqueue(recordSet *fluent.FluentRecordSet) int64

func (*MessageQueue) Len

func (q *MessageQueue) Len() int

type Monitor

type Monitor struct {
	Addr net.Addr
	// contains filtered or unexported fields
}

func NewMonitor

func NewMonitor(config *Config, monitorCh chan Stat) (*Monitor, error)

func (*Monitor) Run

func (m *Monitor) Run()

type OutForward

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

func NewOutForward

func NewOutForward(configServers []*ConfigServer, messageCh chan *fluent.FluentRecordSet, monitorCh chan Stat) (*OutForward, error)

OutForward ... recieve FluentRecordSet from channel, and send it to passed loggers until success.

func (*OutForward) Run

func (f *OutForward) Run()

type ReceiverStat added in v0.0.2

type ReceiverStat struct {
	Address            string `json:"address"`
	Connections        int    `json:"-"`
	TotalConnections   int    `json:"total_connections"`
	CurrentConnections int    `json:"current_connections"`
	Messages           int64  `json:"messages"`
	Disposed           int64  `json:"disposed"`
	Buffered           int64  `json:"buffered"`
	MaxBufferMessages  int64  `json:"max_buffer_messages"`
}

func (*ReceiverStat) ApplyTo added in v0.0.2

func (s *ReceiverStat) ApplyTo(ss *Stats)

type SentStat

type SentStat struct {
	Tag      string `json:"-"`
	Messages int64  `json:"messages"`
	Bytes    int64  `json:"bytes"`
}

func (*SentStat) ApplyTo

func (s *SentStat) ApplyTo(ss *Stats)

type ServerStat

type ServerStat struct {
	Index   int    `json:"-"`
	Address string `json:"address"`
	Alive   bool   `json:"alive"`
	Error   string `json:"error"`
}

func (*ServerStat) ApplyTo

func (s *ServerStat) ApplyTo(ss *Stats)

type ShutdownType

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

func (*ShutdownType) Error

func (s *ShutdownType) Error() string

type Stat

type Stat interface {
	ApplyTo(*Stats)
}

type Stats

type Stats struct {
	Sent     map[string]*SentStat `json:"sent"`
	Files    map[string]*FileStat `json:"files"`
	Servers  []*ServerStat        `json:"servers"`
	Receiver *ReceiverStat        `json:"receiver"`
	// contains filtered or unexported fields
}

func (*Stats) Run

func (ss *Stats) Run(ch chan Stat)

func (*Stats) WriteJSON

func (ss *Stats) WriteJSON(w http.ResponseWriter)

type Watcher

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

func NewWatcher

func NewWatcher() (*Watcher, error)

func (*Watcher) Run

func (w *Watcher) Run()

func (*Watcher) WatchFile

func (w *Watcher) WatchFile(filename string) (chan *fsnotify.FileEvent, error)

Jump to

Keyboard shortcuts

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