sm

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Created int32 = iota
	Running
	ReceiverStopped
	PrepareStop
	Stopped
)

Variables

View Source
var (
	ErrClose = moerr.NewInternalErrorNoCtx("closed")
	ErrFull  = moerr.NewInternalErrorNoCtx("nonblocking queue is full, dropped item")
)

Functions

func NewNonBlockingQueue added in v1.0.0

func NewNonBlockingQueue(queueSize int, batchSize int, onItem OnItemsCB) *safeQueue

func NewSafeQueue

func NewSafeQueue(queueSize, batchSize int, onItem OnItemsCB) *safeQueue

NewSafeQueue is blocking queue by default

func NewStateMachine

func NewStateMachine(wg *sync.WaitGroup, closed Closable, rQueue, ckpQueue Queue) *stateMachine

Types

type Closable added in v0.8.0

type Closable interface {
	IsClosed() bool
	TryClose() bool
}

type ClosedState added in v0.8.0

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

func (*ClosedState) IsClosed added in v0.8.0

func (c *ClosedState) IsClosed() bool

func (*ClosedState) TryClose added in v0.8.0

func (c *ClosedState) TryClose() bool

type EnqueueOp

type EnqueueOp = func(any) any

type Loop added in v0.6.0

type Loop struct {
	Itemcount int
	Itemtimes int
	// contains filtered or unexported fields
}

func NewLoop added in v0.6.0

func NewLoop(queue, nextQueue chan any, fn func([]any, chan any), maxBatchSize int) *Loop

func (*Loop) Start added in v0.6.0

func (l *Loop) Start()

func (*Loop) Stop added in v0.6.0

func (l *Loop) Stop()

type OnFinCB

type OnFinCB = func()

type OnItemsCB

type OnItemsCB = func(...any)

type Queue

type Queue interface {
	Start()
	Stop()

	// Enqueue puts an item into this queue
	// it will return directly when if it is an unblocking queue and there has no more free space,
	// and ErrFull will be return to notify the producer.
	Enqueue(any) (any, error)
}

type StateMachine

type StateMachine interface {
	Start()
	Stop()
	EnqueueRecevied(any) (any, error)
	EnqueueCheckpoint(any) (any, error)
}

Jump to

Keyboard shortcuts

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