control

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package control provides abstractions for managing job states and security flags.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTerminal = errors.New("job is in a terminal state")
)

Functions

func TestFlagReg32Concurrent

func TestFlagReg32Concurrent(t *testing.T)

func TestFlagReg32SetAndClear

func TestFlagReg32SetAndClear(t *testing.T)

func TestJobStateTransitions

func TestJobStateTransitions(t *testing.T)

Types

type FlagReg32

type FlagReg32[T ~uint32] struct {
	// contains filtered or unexported fields
}

func (*FlagReg32[T]) All

func (r *FlagReg32[T]) All(mask T) bool

func (*FlagReg32[T]) Any

func (r *FlagReg32[T]) Any(mask T) bool

func (*FlagReg32[T]) Clear

func (r *FlagReg32[T]) Clear(mask T)

func (*FlagReg32[T]) Load

func (r *FlagReg32[T]) Load() T

func (*FlagReg32[T]) Set

func (r *FlagReg32[T]) Set(mask T)

func (*FlagReg32[T]) SetIf

func (r *FlagReg32[T]) SetIf(clearMask, setMask T) bool

func (*FlagReg32[T]) Store

func (r *FlagReg32[T]) Store(val T)

type FlagReg32A

type FlagReg32A[T ~uint32] struct {
	// contains filtered or unexported fields
}

func (*FlagReg32A[T]) Clear

func (r *FlagReg32A[T]) Clear(mask T)

Clear CAS AND NOT

func (*FlagReg32A[T]) Load

func (r *FlagReg32A[T]) Load() T

Load current value

func (*FlagReg32A[T]) Set

func (r *FlagReg32A[T]) Set(mask T)

Set CAS OR (não usa Add; evita somas indevidas quando máscara tem múltiplos bits)

func (*FlagReg32A[T]) SetIf

func (r *FlagReg32A[T]) SetIf(mask, mustHave T) bool

SetIf CAS OR se todos os bits de mustHave estiverem setados

type JobFlag

type JobFlag uint32
const (
	JobPendingA JobFlag = 1 << iota
	JobRunningA
	JobCancelRequestedA
	JobRetryingA
	JobCompletedA
	JobFailedA
	JobTimedOutA
)

func (JobFlag) Has

func (j JobFlag) Has(flag JobFlag) bool

type JobFlagC

type JobFlagC uint32
const (
	JobNone     JobFlagC = 0
	JobRunningC JobFlagC = 1 << iota
	JobRetryingC
	JobCompletedC
	JobFailedC
	JobTimedOutC
)

func (JobFlagC) Has

func (f JobFlagC) Has(mask JobFlagC) bool

func (JobFlagC) String

func (f JobFlagC) String() string

String returns a string representation of the JobFlagC flags that are set. The output is a sorted, pipe-separated list of flag names (e.g., "completed|running"). If no flags are set, it returns "none".

type JobState

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

func (*JobState) Complete

func (s *JobState) Complete() error

Complete sets the job state to Completed.

func (*JobState) Fail

func (s *JobState) Fail() error

Fail sets the job state to Failed.

func (*JobState) IsTerminal

func (s *JobState) IsTerminal() bool

IsTerminal returns true if the job is in a terminal state.

func (*JobState) Load

func (s *JobState) Load() JobFlag

func (*JobState) RequestCancel

func (s *JobState) RequestCancel()

RequestCancel sets the CancelRequested flag.

func (*JobState) Retry

func (s *JobState) Retry() error

Retry sets the job state to Retrying if not in a terminal state.

func (*JobState) Start

func (s *JobState) Start() error

Start only from Pending; sets Running.

func (*JobState) Timeout

func (s *JobState) Timeout() error

Timeout sets the job state to TimedOut.

type JobStateS

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

func (*JobStateS) Complete

func (s *JobStateS) Complete()

func (*JobStateS) Fail

func (s *JobStateS) Fail()

func (*JobStateS) Load

func (s *JobStateS) Load() JobFlagC

func (*JobStateS) Retry

func (s *JobStateS) Retry()

func (*JobStateS) Start

func (s *JobStateS) Start()

func (*JobStateS) Timeout

func (s *JobStateS) Timeout()

type SecFlag

type SecFlag uint32
const (
	SecNone         SecFlag = 0
	SecAuth         SecFlag = 1 << iota // autenticação/autorização
	SecSanitize                         // sanitize em params/headers
	SecSanitizeBody                     // sanitize no body
)

func FromLegacyMap

func FromLegacyMap(m map[string]bool) SecFlag

FromLegacyMap converte mapa legado (ex: de config JSON) para flags

func (SecFlag) Any

func (f SecFlag) Any(mask SecFlag) bool

func (SecFlag) Has

func (f SecFlag) Has(mask SecFlag) bool

func (SecFlag) String

func (f SecFlag) String() string

func (SecFlag) With

func (f SecFlag) With(mask SecFlag) SecFlag

func (SecFlag) Without

func (f SecFlag) Without(mask SecFlag) SecFlag

Jump to

Keyboard shortcuts

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