types

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2019 License: Apache-2.0 Imports: 7 Imported by: 38

Documentation

Index

Constants

View Source
const (
	DefaultKeepAlive        = 60 // DefaultKeepAlive default keep
	DefaultConnectTimeout   = 5  // DefaultConnectTimeout connect timeout
	DefaultMaxPacketSize    = 268435455
	DefaultReceiveMax       = 65535
	DefaultAckTimeout       = 20 // DefaultAckTimeout ack timeout
	DefaultTimeoutRetries   = 3  // DefaultTimeoutRetries retries
	MinKeepAlive            = 30
	DefaultSessionsProvider = "mem"         // DefaultSessionsProvider default session provider
	DefaultAuthenticator    = "mockSuccess" // DefaultAuthenticator default auth provider
	DefaultTopicsProvider   = "mem"         // DefaultTopicsProvider default topics provider
)

Default configs

Variables

View Source
var ErrClosed = fmt.Errorf("pool: closed")

ErrClosed notify object was stopped

View Source
var ErrScheduleTimeout = fmt.Errorf("pool: schedule error: timed out")

ErrScheduleTimeout returned by Pool to indicate that there no free goroutines during some period of time.

Functions

This section is empty.

Types

type LogInterface

type LogInterface struct {
	Prod *zap.Logger
	Dev  *zap.Logger
}

LogInterface inherited by internal packages to provide hierarchical logs

type Once

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

Once is an object that will perform exactly one action.

func (*Once) Do

func (o *Once) Do(f func()) bool

Do calls the function f if and only if Do is being called for the first time for this instance of Once. In other words, given

var once Once

if once.Do(f) is called multiple times, only the first call will invoke f, even if f has a different value in each invocation. A new instance of Once is required for each function to execute.

Do is intended for initialization that must be run exactly once. Since f is niladic, it may be necessary to use a function literal to capture the arguments to a function to be invoked by Do:

config.once.Do(func() { config.init(filename) })

Because no call to Do returns until the one call to f returns, if f causes Do to be called, it will deadlock.

If f panics, Do considers it to have returned; future calls of Do return without calling f.

type OnceWait

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

OnceWait is an object that will perform exactly one action.

func (*OnceWait) Do

func (o *OnceWait) Do(f func()) bool

Do calls the function f if and only if Do is being called for the first time for this instance of Once. In other words, given

var once Once

if once.Do(f) is called multiple times, only the first call will invoke f, even if f has a different value in each invocation. A new instance of Once is required for each function to execute.

Do is intended for initialization that must be run exactly once. Since f is niladic, it may be necessary to use a function literal to capture the arguments to a function to be invoked by Do:

config.once.Do(func() { config.init(filename) })

Because no call to Do returns until the one call to f returns, if f causes Do to be called, it will deadlock.

If f panics, Do considers it to have returned; future calls of Do return without calling f.

type Pool added in v0.2.5

type Pool interface {
	Schedule(task func()) error
	ScheduleTimeout(timeout time.Duration, task func()) error
	Close() error
}

Pool implements logic of goroutine reuse.

func NewPool added in v0.2.5

func NewPool(size, queue, spawn int) Pool

NewPool creates new goroutine pool with given size. It also creates a work queue of given size. Finally, it spawns given amount of goroutines immediately.

type Queue added in v0.2.2

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

Queue represents a single instance of the queue data structure.

func NewQueue added in v0.2.2

func NewQueue() *Queue

NewQueue constructs and returns a new Queue.

func (*Queue) Add added in v0.2.2

func (q *Queue) Add(elem interface{})

Add puts an element on the end of the queue.

func (*Queue) Get added in v0.2.2

func (q *Queue) Get(i int) interface{}

Get returns the element at index i in the queue. If the index is invalid, the call will panic. This method accepts both positive and negative index values. Index 0 refers to the first element, and index -1 refers to the last.

func (*Queue) Length added in v0.2.2

func (q *Queue) Length() int

Length returns the number of elements currently stored in the queue.

func (*Queue) Peek added in v0.2.2

func (q *Queue) Peek() interface{}

Peek returns the element at the head of the queue. This call panics if the queue is empty.

func (*Queue) Remove added in v0.2.2

func (q *Queue) Remove() interface{}

Remove removes and returns the element from the front of the queue. If the queue is empty, the call will panic.

type RetainObject

type RetainObject interface {
	Topic() string
}

RetainObject general interface of the retain as not only publish message can be retained

type TopicMessenger

type TopicMessenger interface {
	Publish(interface{}) error
	Retain(RetainObject) error
}

TopicMessenger interface for session or systree used to publish or retain messages

type WritePool added in v0.2.6

type WritePool interface {
	Get(io.Reader) *bufio.Reader
	Put(*bufio.Reader)
}

func NewWritePool added in v0.2.6

func NewWritePool(size, preAlloc, grow, shrink int) (WritePool, error)

Jump to

Keyboard shortcuts

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