publisher

package
v1.3000030.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 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 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 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