Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrZeroTimeout = errors.New("zero timeout") ErrTooSmallFrequency = errors.New("the frequency is too small") )
var ErrWGExpired = errors.New("wait group timeout expired")
ErrWGExpired is returned if the timeout expires before the WaitGroup has received a "Done" confirmation from all of the streams.
Functions ¶
Types ¶
type Event ¶
type Event int
const ( // EventDisconnect occurs when the connection is down. EventDisconnect Event = iota // EventDisconnect occurs when the connection is up. EventConnect // EventStopped occurs when the handler is stopped. EventStopped // EventLogon occurs upon receiving the Logon message. EventLogon // EventRequest occurs upon sending the Logon message, // after which the Session awaits an answer from the counterparty. EventRequest // EventLogout occurs upon receiving the Logout message. EventLogout )
type EventHandlerFunc ¶
type EventHandlerFunc func() bool
EventHandlerFunc is called when an event occurs.
type EventHandlerPool ¶
type EventHandlerPool struct {
// contains filtered or unexported fields
}
EventHandlerPool is a service required for saving and calling the event handlers.
func NewEventHandlerPool ¶
func NewEventHandlerPool() *EventHandlerPool
NewEventHandlerPool creates a new EventHandlerPool instance.
func (*EventHandlerPool) Clean ¶
func (evp *EventHandlerPool) Clean()
func (*EventHandlerPool) Handle ¶
func (evp *EventHandlerPool) Handle(e Event, handle EventHandlerFunc)
Handle adds a new handler for an event.
func (*EventHandlerPool) Trigger ¶
func (evp *EventHandlerPool) Trigger(e Event)
Trigger calls all handlers associated with an occurring event.
type TimedWaitGroup ¶
TimedWaitGroup is a combination of WaitGroup and timeout
func (*TimedWaitGroup) WaitWithTimeout ¶
func (wg *TimedWaitGroup) WaitWithTimeout(timeout time.Duration) error
WaitWithTimeout awaits any of the two cases: - timeout expires (in which case an error is returned) - a WaitGroup receives a "Done" confirmation (in which case nil is returned)
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
func (*Timer) TakeTimeout ¶
func (t *Timer) TakeTimeout()
TakeTimeout will be in action until timeout is reached or the Close method is called.