{"modulePath":"github.com/eric-erki/https-hyperledger.org","version":"v0.6.1-preview","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package events\n\n## Functions\n\n```go\nfunc SendEvent(receiver Receiver, event Event)\n```\nSendEvent performs the event loop on a receiver to completion\n\n## Types\n\n```go\ntype Event interface{}\n```\nEvent is a type meant to clearly convey that the return type or parameter to a function will be supplied to/from an events.Manager\n\n```go\ntype Manager interface {\n\tInject(Event)         // A temporary interface to allow the event manager thread to skip the queue\n\tQueue() chan\u003c- Event  // Get a write-only reference to the queue, to submit events\n\tSetReceiver(Receiver) // Set the target to route events to\n\tStart()               // Starts the Manager thread TODO, these thread management things should probably go away\n\tHalt()                // Stops the Manager thread\n}\n```\nManager provides a serialized interface for submitting events to a Receiver on the other side of the queue\n\n```go\nfunc NewManagerImpl() Manager\n```\nNewManagerImpl creates an instance of managerImpl\n\n```go\ntype Receiver interface {\n\t// ProcessEvent delivers an event to the Receiver, if it returns non-nil, the return is the next processed event\n\tProcessEvent(e Event) Event\n}\n```\nReceiver is a consumer of events, ProcessEvent will be called serially as events arrive\n\n```go\ntype Timer interface {\n\tSoftReset(duration time.Duration, event Event) // start a new countdown, only if one is not already started\n\tReset(duration time.Duration, event Event)     // start a new countdown, clear any pending events\n\tStop()                                         // stop the countdown, clear any pending events\n\tHalt()                                         // Stops the Timer thread\n}\n```\nTimer is an interface for managing time driven events the special contract Timer gives which a traditional golang timer does not, is that if the event thread calls stop, or reset then even if the timer has already fired, the event will not be delivered to the event queue\n\n```go\ntype TimerFactory interface {\n\tCreateTimer() Timer // Creates an Timer which is stopped\n}\n```\nTimerFactory abstracts the creation of Timers, as they may need to be mocked for testing\n\n```go\nfunc NewTimerFactoryImpl(manager Manager) TimerFactory\n```\nNewTimerFactoryImpl creates a new TimerFactory for the given Manager\n\n","path":"github.com/eric-erki/https-hyperledger.org/consensus/util/events","name":"events","synopsis":"","isRedistributable":true}
