models

package
v0.0.6-beta Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadContext = errors.New("bad_context")
View Source
var ErrBadParam = errors.New("bad_param")
View Source
var ErrDuplicate = errors.New("duplicate")
View Source
var ErrNoLuck = errors.New("no_luck")
View Source
var ErrNotFound = errors.New("not_found")
View Source
var ErrNotSupported = errors.New("not_supported")
View Source
var ErrWrongState = errors.New("wrong_state")

Functions

This section is empty.

Types

type Lock

type Lock struct {
	// Unique lock name
	Name string

	// Duration of lock in seconds (TTL)
	ExecutionDurationSec int

	// Interval between locks execution in seconds
	SpanDurationSec int

	// Additional lock check period
	CheckPeriodSec int
}

func NewLock

func NewLock(
	name string,
	executionDurationSec int,
	spanDurationSec int,
) (lock Lock, err error)

func NewLockPnc

func NewLockPnc(
	name string,
	executionDurationSec int,
	spanDurationSec int,
) (lock Lock)

func (Lock) GetDurationSec

func (j Lock) GetDurationSec() int

Total lock period

func (*Lock) SetCheckPeriod

func (l *Lock) SetCheckPeriod(checkPeriodSec int) (err error)

func (Lock) Validate

func (j Lock) Validate() (err error)

type LockRecord

type LockRecord struct {
	LockName    string
	Version     string
	DurationSec int
	State       LockRecordState
	Dt          time.Time
}

func NewLockRecord

func NewLockRecord(
	lock Lock,
) LockRecord

func (*LockRecord) ApplyPatch

func (lr *LockRecord) ApplyPatch(patch LockRecordPatch)

type LockRecordPatch

type LockRecordPatch struct {
	Version     string
	DurationSec int
	State       LockRecordState
	Dt          time.Time
}

func NewLockRecordPatchForCapture

func NewLockRecordPatchForCapture(
	durationSec int,
) LockRecordPatch

func NewLockRecordPatchForRelease

func NewLockRecordPatchForRelease(curVersion string) LockRecordPatch

type LockRecordState

type LockRecordState string
const (
	LockRecordStateNone   LockRecordState = ""
	LockRecordStateLock   LockRecordState = "lock"
	LockRecordStateUnlock LockRecordState = "unlock"
)

func (LockRecordState) IsLock

func (state LockRecordState) IsLock() bool

Jump to

Keyboard shortcuts

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