ctl

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AcquisitionCtl

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

AcquisitionCtl is a primitive for controlling acquisition status.

func NewAcquisitionCtl

func NewAcquisitionCtl(max int64, acquired map[string]int64) *AcquisitionCtl

NewAcquisitionCtl creates new AcquisitionCtl.

func (*AcquisitionCtl) Acquire

func (c *AcquisitionCtl) Acquire(ctx context.Context, operator string, exclusive bool) (<-chan AcquisitionResult, bool)

Acquire acquires exclusive/shared lock.

func (*AcquisitionCtl) Acquired added in v0.0.4

func (c *AcquisitionCtl) Acquired(operator string) bool

func (*AcquisitionCtl) Release

func (c *AcquisitionCtl) Release(operator string) bool

Release releases acquired lock.

type AcquisitionResult

type AcquisitionResult struct {
	Acquired int64
	Err      error
}

type InitCtl

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

InitCtl is a primitive for controlling init status.

func NewInitCtl

func NewInitCtl(completed bool) *InitCtl

NewInitCtl creates new InitCtl.

func (*InitCtl) Complete

func (i *InitCtl) Complete(operator string) error

Complete marks init operation as completed.

func (*InitCtl) Fail

func (i *InitCtl) Fail(operator string) error

Fail marks init operation as failed.

func (*InitCtl) TryInit

func (i *InitCtl) TryInit(ctx context.Context, operator string) <-chan TryInitResult

TryInit tries to acquire lock and start init operation. When operation is already completed, 'try' will be false.

type TryInitResult

type TryInitResult struct {
	Try       bool
	Initiated bool
	Err       error
}

Jump to

Keyboard shortcuts

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