priorityblocker

package
v0.0.0-...-ec6225e Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: Apache-2.0 Imports: 1 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blocker

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

Blocker provides a function which can block some process. Unblock strategy bases on Priority. The higher the priority, the earlier it will be unblocked. Unblocking is done by consuming tickets. If ticket chan is nil when new a Blocker, Blocker will keep printing tickets itself.

func NewBlocker

func NewBlocker(ticketChan <-chan struct{}) *Blocker

NewBlocker create a new Blocker instance.

func (*Blocker) Block

func (b *Blocker) Block(flag string)

Block the process, until a ticket with the priority of the flag consumed.

func (*Blocker) Close

func (b *Blocker) Close()

Close the blocker.

func (*Blocker) GetPriority

func (b *Blocker) GetPriority(flag string) Priority

GetPriority query the priority of the flag. If never set, will return PriorityLevel5.

func (*Blocker) Run

func (b *Blocker) Run()

Run start a goroutine to print tickets.

func (*Blocker) SetPriority

func (b *Blocker) SetPriority(flag string, p Priority)

SetPriority set the priority of the flag.

type Priority

type Priority uint8

Priority for blocking with blocker.

const (
	PriorityLevel0 Priority = iota
	PriorityLevel1
	PriorityLevel2
	PriorityLevel3
	PriorityLevel4
	PriorityLevel5
	PriorityLevel6
	PriorityLevel7
	PriorityLevel8
	PriorityLevel9
)

Jump to

Keyboard shortcuts

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