Documentation ¶
Index ¶
- Constants
- type Actor
- type BaseDaemon
- func (d *BaseDaemon) Continue() bool
- func (d *BaseDaemon) HandlePanics(f PanicHandler)
- func (d *BaseDaemon) LimitRate(times int, per time.Duration)
- func (d *BaseDaemon) Log(v ...interface{})
- func (d *BaseDaemon) Logf(format string, v ...interface{})
- func (d *BaseDaemon) Process(a Actor)
- func (d *BaseDaemon) Publish(topic string, msg []byte, meta interface{})
- func (d *BaseDaemon) Shutdown()
- func (d *BaseDaemon) ShutdownRequested() <-chan struct{}
- func (d *BaseDaemon) String() string
- func (d *BaseDaemon) Subscribe(topic string, fun interface{})
- func (d *BaseDaemon) SystemProcess(name string, a Actor)
- type Daemon
- type Logger
- type PanicHandler
- type Publisher
- type Shezmu
- type Streamer
- type Subscriber
Constants ¶
const ( // DefaultNumWorkers is the default number of workers that would process // tasks. DefaultNumWorkers = 100 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseDaemon ¶
type BaseDaemon struct {
// contains filtered or unexported fields
}
BaseDaemon is the parent structure for all daemons.
func (*BaseDaemon) Continue ¶
func (d *BaseDaemon) Continue() bool
Continue returns true if daemon should proceed and false if it should stop.
func (*BaseDaemon) HandlePanics ¶
func (d *BaseDaemon) HandlePanics(f PanicHandler)
HandlePanics sets up a panic handler function for the daemon.
func (*BaseDaemon) LimitRate ¶
func (d *BaseDaemon) LimitRate(times int, per time.Duration)
LimitRate limits the daemons' processing rate.
func (*BaseDaemon) Log ¶
func (d *BaseDaemon) Log(v ...interface{})
Log logs values using shezmu.Logger.Println function.
func (*BaseDaemon) Logf ¶
func (d *BaseDaemon) Logf(format string, v ...interface{})
Logf logs values using shezmu.Logger.Printf function.
func (*BaseDaemon) Process ¶
func (d *BaseDaemon) Process(a Actor)
Process creates a task and then adds it to processing queue.
func (*BaseDaemon) Publish ¶
func (d *BaseDaemon) Publish(topic string, msg []byte, meta interface{})
Publish sends a message to the publisher.
func (*BaseDaemon) Shutdown ¶
func (d *BaseDaemon) Shutdown()
Shutdown is the empty implementation of the daemons' Shutdown function that is inherited and used by default.
func (*BaseDaemon) ShutdownRequested ¶
func (d *BaseDaemon) ShutdownRequested() <-chan struct{}
ShutdownRequested returns a channel that is closed the moment daemon shutdown is requested.
func (*BaseDaemon) String ¶
func (d *BaseDaemon) String() string
String returns the name of the Deamon unerlying struct.
func (*BaseDaemon) Subscribe ¶
func (d *BaseDaemon) Subscribe(topic string, fun interface{})
Subscribe subscriasdsdfsdgdfgdfsg sdgsdfg sdfgs dfgdfgdfg.
func (*BaseDaemon) SystemProcess ¶
func (d *BaseDaemon) SystemProcess(name string, a Actor)
SystemProcess creates a system task that is restarted in case of failure and then adds it to processing queue.
type Daemon ¶
type Daemon interface { // Startup implementation should: // // func (d *DaemonName) Startup() { // // 1. Set up a panic handler // b.HandlePanics(func() { // log.Error("Oh, crap!") // }) // // // 2. If the daemon is doing some IO it is a good idea to limit the // // rate of its execution // b.LimitRate(10, 1 * time.Second) // // // 3. If the daemon is also a consumer we need to subscribe for // // topics that would be consumed by the daemon // b.Subscribe("ProductPriceUpdates", func(p PriceUpdate) { // log.Printf("Price for %q is now $%.2f", p.Product, p.Amount) // }) // } Startup() // Shutdown implementation should clean up all daemon related stuff: // close channels, process the last batch of items, etc. Shutdown() // String returns the name of a daemon. String() string // contains filtered or unexported methods }
Daemon is the interface that contains a set of methods required to be implemented in order to be treated as a daemon.
type Logger ¶
type Logger interface { Printf(format string, v ...interface{}) Println(v ...interface{}) }
Logger is the interface that implements minimal logging functions.
type PanicHandler ¶
type PanicHandler func(interface{})
PanicHandler is a function that handles panics. Duh!
type Publisher ¶
Publisher is the interface that wraps message publishers. Error handling should be provided by the implementation. Feel free to panic.
type Shezmu ¶
type Shezmu struct { Subscriber Subscriber Publisher Publisher DaemonStats stats.Publisher Logger Logger NumWorkers int // contains filtered or unexported fields }
Shezmu is the master daemon.
func (*Shezmu) ClearDaemons ¶
func (s *Shezmu) ClearDaemons()
ClearDaemons clears the list of added daemons. StopDaemons() function MUST be called before calling ClearDaemons().
func (*Shezmu) StartDaemons ¶
func (s *Shezmu) StartDaemons()
StartDaemons starts all registered daemons.
type Streamer ¶
type Streamer interface { Messages() <-chan []byte Close() }
Streamer is the interface that wraps message consumers. Error handling should be provided by the implementation. Feel free to panic.
type Subscriber ¶
Subscriber is the interface that is used by daemons to subscribe to messages.