utils

package
v1.14.4 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrZeroTimeout       = errors.New("zero timeout")
	ErrTooSmallFrequency = errors.New("the frequency is too small")
)
View Source
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

func ParseXML

func ParseXML(path string, data interface{}) error

ParseXML is used to unmarshal an XML schema into a Go structure.

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

type TimedWaitGroup struct {
	sync.WaitGroup
}

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 NewTimer

func NewTimer(timeout time.Duration) (*Timer, error)

func (*Timer) Close

func (t *Timer) Close()

func (*Timer) Refresh

func (t *Timer) Refresh()

func (*Timer) TakeTimeout

func (t *Timer) TakeTimeout()

TakeTimeout will be in action until timeout is reached or the Close method is called.

Jump to

Keyboard shortcuts

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