lockedcallbacks

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lockedcallbacks provides locking per-key.

Index

Constants

This section is empty.

Variables

View Source
var ErrStateKeyNotFound error = errors.New("Unlock requested for an unknown state")

ErrStateKeyNotFound indicates the requested key was not found in the map of states

Functions

This section is empty.

Types

type Mstate

type Mstate struct {
	Callback           func(string) string // points to the callback to protect
	AllowFlagsCallback func(string) string // points to the allowflags callback to protect
	// contains filtered or unexported fields
}

Mstate is used to represent entries of StatesMap each entry (Mstate) holds a callback. A mutex is protecting changes to the callback The key and statesmap attributes are used to provide self-cleaning of the entries once a state does not need to be maintained.

type StatesMap

type StatesMap struct {
	States map[any]*Mstate // contains states for each template
	// contains filtered or unexported fields
}

StatesMap wraps a map of Mstate. Each key locks separately.

func New

func New() *StatesMap

New returns an initialized StatesMap.

func (*StatesMap) BuildAllowFlagsCallbackFunc

func (m *StatesMap) BuildAllowFlagsCallbackFunc(safeTmplUUID string, wrapperFunc func(any, func(string) string) any) func(data any) any

BuildAllowFlagsCallbackFunc creates a virtual method calling the template's allowFlags callback.

func (*StatesMap) BuildTextTemplateRemediationFunc

func (m *StatesMap) BuildTextTemplateRemediationFunc(safeTmplUUID string, wrapperFunc func(any, func(string) string) any) func(any) any

BuildTextTemplateRemediationFunc creates a virtual method calling the template's callback.

func (*StatesMap) SetAndExecuteWithCallback

func (m *StatesMap) SetAndExecuteWithCallback(tmpl *template.Template, safeTmplUUID string, cb func(string) string, result io.Writer, data any) error

SetAndExecuteWithCallback hides implementation details of the StatesMap by taking a template and a callback to set the proper callback and execute the template.

func (*StatesMap) SetAndExecuteWithShCallback

func (m *StatesMap) SetAndExecuteWithShCallback(tmpl *template.Template, safeTmplUUID string, cb func(string) string, allowFlagsCb func(string) string, result io.Writer, data any) error

SetAndExecuteWithShCallback hides implementation details of the StatesMap by taking a template and both callbacks to set the proper callback and execute the template.

Jump to

Keyboard shortcuts

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