event

package
v0.0.0-...-7cb0e1f Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Event package is responsible for receiving events from 9volt components and dumping them to etcd. The event queue is powered by WORKER_COUNT workers and has a BUFFER_LEN buffer.

Unlike other components, the event queue does NOT get shutdown in the event of a backend failure - it gets *paused*. In the *pause* state, the event queue will simply discard any inbound messages and will NOT attempt to save them to the backend.

This is done in order to avoid potential race conditions where lagging/slower components continue to write to the event queue even though they've been asked to shutdown.

Index

Constants

View Source
const (
	BUFFER_LEN    = 1000
	WORKER_COUNT  = 20
	WORKER_SLEEP  = time.Duration(500) * time.Millisecond
	MAX_EVENT_AGE = 86400 // 24 hours
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func (*Client) Add

func (c *Client) Add(key, value string) error

Attempt to send an event to the event channel; discard event if event channel is full

func (*Client) AddWithErrorLog

func (c *Client) AddWithErrorLog(value string, logger log.FieldLogger, fields log.Fields) error

Helper for AddWithLog()

func (*Client) AddWithLog

func (c *Client) AddWithLog(key, value string, logger log.FieldLogger, fields log.Fields) error

type Event

type Event struct {
	Type      string    `json:"type"`
	Message   string    `json:"message"`
	Timestamp time.Time `json:"timestamp"`
	MemberId  string    `json:"memberid"`
}

type IClient

type IClient interface {
	Add(string, string) error
	AddWithErrorLog(string, log.FieldLogger, log.Fields) error
	AddWithLog(string, string, log.FieldLogger, log.Fields) error
}

type Queue

type Queue struct {
	Log       log.FieldLogger
	DalClient dal.IDal
	MemberID  string

	Running bool // do not allow more than one Start() to be issued; resets Pause
	Pause   bool // Pause set via Stop(); causes messages to be discarded

	base.Component
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue(memberID string, dalClient dal.IDal) *Queue

func (*Queue) NewClient

func (q *Queue) NewClient() *Client

func (*Queue) Start

func (q *Queue) Start() error

func (*Queue) Stop

func (q *Queue) Stop() error

Jump to

Keyboard shortcuts

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