publisher

package
v1.247359.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockingFifoQueue

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

It is a FIFO queue with the functionality that block the caller if the queue size reaches to the maxSize

func NewBlockingFifoQueue

func NewBlockingFifoQueue(size int) *BlockingFifoQueue

func (*BlockingFifoQueue) Dequeue

func (b *BlockingFifoQueue) Dequeue() (interface{}, bool)

func (*BlockingFifoQueue) Enqueue

func (b *BlockingFifoQueue) Enqueue(req interface{})

type NonBlockingFifoQueue

type NonBlockingFifoQueue struct {
	sync.Mutex
	// contains filtered or unexported fields
}

It is a FIFO queue with the functionality that dropping the front if the queue size reaches to the maxSize

func NewNonBlockingFifoQueue

func NewNonBlockingFifoQueue(size int) *NonBlockingFifoQueue

func (*NonBlockingFifoQueue) Dequeue

func (u *NonBlockingFifoQueue) Dequeue() (interface{}, bool)

func (*NonBlockingFifoQueue) Enqueue

func (u *NonBlockingFifoQueue) Enqueue(value interface{})

type NonBlockingLifoQueue

type NonBlockingLifoQueue struct {
	sync.Mutex
	// contains filtered or unexported fields
}

It is a LIFO queue with the functionality that dropping the tail if the queue size reaches to the maxSize

func NewNonBlockingLifoQueue

func NewNonBlockingLifoQueue(size int) *NonBlockingLifoQueue

func (*NonBlockingLifoQueue) Dequeue

func (u *NonBlockingLifoQueue) Dequeue() (interface{}, bool)

func (*NonBlockingLifoQueue) Enqueue

func (u *NonBlockingLifoQueue) Enqueue(value interface{})

enqueue to the head of the queue, delete the tail if the queue has already reached to maxSize

type Publisher

type Publisher struct {

	// After close is set to true, subsequent calling Publish will be a no-op
	sync.RWMutex
	// contains filtered or unexported fields
}

Publisher is go-routing safe

func NewPublisher

func NewPublisher(queue Queue, concurrency int64, drainTimeout time.Duration, fn func(req interface{})) (*Publisher, error)

Create a publisher with parameters: queue: specify the underlining queue concurrency: specify the worker thread to consume the queue drainTimeout: time to wait for draining the on-hold requests when calling Close() fn: specify the publishing method to call

func (*Publisher) Close

func (p *Publisher) Close()

func (*Publisher) Publish

func (p *Publisher) Publish(req interface{})

type Queue

type Queue interface {
	Enqueue(req interface{})
	Dequeue() (interface{}, bool)
}

Queue is go-routing safe

Jump to

Keyboard shortcuts

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