priorityblocker

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: Apache-2.0 Imports: 1 Imported by: 6

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 . @Description: create a new Blocker instance. @param ticketChan: @return *Blocker:

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 level0
	PriorityLevel0 Priority = iota
	// PriorityLevel1 level1
	PriorityLevel1
	// PriorityLevel2 level2
	PriorityLevel2
	// PriorityLevel3 level3
	PriorityLevel3
	// PriorityLevel4 level4
	PriorityLevel4
	// PriorityLevel5 level5
	PriorityLevel5
	// PriorityLevel6 level6
	PriorityLevel6
	// PriorityLevel7 level7
	PriorityLevel7
	// PriorityLevel8 level8
	PriorityLevel8
	// PriorityLevel9 level9
	PriorityLevel9
)

Jump to

Keyboard shortcuts

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