tunings

package
v0.0.1-dev-893fa2f Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Module    = "tunings"
	RecordTTL = 3600
)

Variables

View Source
var (
	Specs = sync.Map{}

	CreateRecordIfNotExist = options.Update().SetUpsert(true)
)

Functions

func CheckSpec

func CheckSpec(tuning Tuning) error

func Collection

func Collection(name string) string

func DB

func DB() string

func GetLocal

func GetLocal() *sync.Map

func GetRolesToHandle

func GetRolesToHandle(tuningName string) ([]*nodes.Role, bool)

func GetSpecs

func GetSpecs() *sync.Map

func ReqCollection

func ReqCollection() string

func SetLocal

func SetLocal(tuning Tuning)

func SetSpec

func SetSpec(name string, spec *Spec)

Types

type Limitation

type Limitation struct {
	Type    string `json:"type"`
	Default any    `json:"default"`
	Min     *int   `json:"min,omitempty"`
	Max     *int   `json:"max,omitempty"`
	Regex   string `json:"regex,omitempty"`
}

type ListOptions

type ListOptions struct {
	AllNodes bool
}

type Policy

type Policy struct {
	Name    string   `json:"name" yaml:"name"`
	Version string   `json:"version" yaml:"version"`
	Enabled bool     `json:"enabled" yaml:"enabled"`
	Tunings []Tuning `json:"tunings" yaml:"tunings"`
}

func (*Policy) AppendTuning

func (p *Policy) AppendTuning(tuning Tuning)

func (*Policy) AppendTunings

func (p *Policy) AppendTunings(tunings []Tuning)

func (*Policy) DeleteTuning

func (p *Policy) DeleteTuning(name string)

func (*Policy) HasMatchedTuning

func (p *Policy) HasMatchedTuning(tuning Tuning) bool

func (*Policy) UpdateOrAppendTuning

func (p *Policy) UpdateOrAppendTuning(tuning Tuning)

type RawLimitation

type RawLimitation struct {
	Type    string `json:"type"`
	Default string `json:"default"`
	Min     string `json:"min,omitempty"`
	Max     string `json:"max,omitempty"`
	Regex   string `json:"regex,omitempty"`
}

type RawSpec

type RawSpec struct {
	Name        string        `json:"name"`
	Description string        `json:"description"`
	Limitation  RawLimitation `json:"limitation"`
}

type Reset

type Reset struct {
	Hosts []string `json:"hosts"`
}

type Spec

type Spec struct {
	Name           string        `json:"name"`
	Description    string        `json:"description"`
	Limitation     Limitation    `json:"limitation"`
	Roles          []*nodes.Role `json:"roles"`
	nodes.Selector `json:"-"`
}

func GetSpec

func GetSpec(name string) (*Spec, error)

func ListSpecs

func ListSpecs() []Spec

func (*Spec) IsInLimitedRange

func (s *Spec) IsInLimitedRange(value int) bool

type Toggle

type Toggle struct {
	Enable bool     `json:"enable"`
	Hosts  []string `json:"hosts"`
}

type Tuning

type Tuning struct {
	Name             string     `json:"name" yaml:"name" bson:"name"`
	Value            any        `json:"value" yaml:"value" bson:"value"`
	Description      string     `json:"description" yaml:"-" bson:"-"`
	Enabled          bool       `json:"enabled" yaml:"enabled" bson:"enabled"`
	IsModified       bool       `json:"isModified" yaml:"-" bson:"-"`
	IsReportRequired bool       `json:"-" yaml:"-" bson:"-"`
	Limitation       Limitation `json:"limitation" yaml:"-" bson:"-"`
	SortIndex        string     `json:"-" yaml:"-" bson:"-"`

	Node   *nodes.Node    `json:"node,omitempty" yaml:"-" bson:"-"`
	Hosts  []nodes.Host   `json:"hosts" yaml:"-" bson:"-"`
	Status *status.Tuning `json:"status,omitempty" yaml:"-" bson:"status,omitempty"`
}

func Get

func Get(name string) Tuning

func ListLocal

func ListLocal() []Tuning

func (*Tuning) Bytes

func (t *Tuning) Bytes() ([]byte, error)

func (*Tuning) CopyAndOverrideHost

func (t *Tuning) CopyAndOverrideHost(n nodes.Node) Tuning

func (*Tuning) GenSearchableOject

func (t *Tuning) GenSearchableOject() Tuning

func (*Tuning) GenTaskUpdate

func (t *Tuning) GenTaskUpdate() Tuning

func (*Tuning) GenerateId

func (t *Tuning) GenerateId() string

func (*Tuning) IncludeHost

func (t *Tuning) IncludeHost(hostname string) bool

func (*Tuning) IncludeHosts

func (t *Tuning) IncludeHosts(hosts []string) bool

func (*Tuning) IndexKey

func (t *Tuning) IndexKey() string

func (*Tuning) InitStatus

func (t *Tuning) InitStatus(current, desired string)

func (*Tuning) JoinHosts

func (t *Tuning) JoinHosts() string

func (*Tuning) SetCompleted

func (t *Tuning) SetCompleted()

func (*Tuning) SetDesired

func (t *Tuning) SetDesired(status string)

func (*Tuning) SetError

func (t *Tuning) SetError()

func (*Tuning) SetHosts

func (t *Tuning) SetHosts(hosts []string)

func (*Tuning) SetNodeInfo

func (t *Tuning) SetNodeInfo(role, address string)

func (*Tuning) SetOk

func (t *Tuning) SetOk()

func (*Tuning) SetResetting

func (t *Tuning) SetResetting()

func (*Tuning) SetUpdated

func (t *Tuning) SetUpdated()

func (*Tuning) SetUpdating

func (t *Tuning) SetUpdating()

func (*Tuning) StrValue

func (t *Tuning) StrValue() string

type Update

type Update struct {
	Value   any      `json:"value"`
	Enabled bool     `json:"enabled"`
	Hosts   []string `json:"hosts"`
}

Jump to

Keyboard shortcuts

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