fqueue

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FunctionCall

type FunctionCall func() error

type FunctionQueue

type FunctionQueue struct {
	Name             string
	CallbackChannels []chan error
	DropCount        int
	// contains filtered or unexported fields
}

FunctionQueue is a queue of function calls (without parameter) that only the head and tail will be executed.

For example: we are calling the same function 5 times in rapid sequence: f1, f2, f3, f4, f5.

f1 will be executed, f2, f3, f4 are discarded and f5 will be executed after f1 has been completed. All 5 callers will be notified after f5 has been completed.

This is a specific use case that we use to build Docker images. If there are multiple goroutines that are trying to build the same image, we only want to build just one image. While building the underlying Dockerfile might have changed, so we need to build one last time for the final request (f5). f2, f3, f4 are discarded as the Dockerfile has changed and those request to build is no longer relevant.

func NewFunctionQueue

func NewFunctionQueue(name string) *FunctionQueue

func NewFunctionQueueWithSize

func NewFunctionQueueWithSize(name string, size int) *FunctionQueue

func (*FunctionQueue) Enqueue

func (fq *FunctionQueue) Enqueue(fn FunctionCall)

func (*FunctionQueue) Execute

func (fq *FunctionQueue) Execute()

func (*FunctionQueue) RegisterCallback

func (fq *FunctionQueue) RegisterCallback(callback chan error)

Jump to

Keyboard shortcuts

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