model

package
v0.5.56 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 28 Imported by: 43

Documentation

Index

Constants

View Source
const (
	ComponentActionStop           = "stop"
	ComponentActionStart          = "start"
	ComponentActionStageFiles     = "stageFiles"
	ComponentActionInitializeHost = "initializeHost"
	ComponentActionInit           = "init"
)
View Source
const (
	DefaultWritePermissions = 0700
	ConfigFileName          = "config.yml"
)
View Source
const (
	EntityTypeModel              = "model"
	EntityTypeRegion             = "region"
	EntityTypeHost               = "host"
	EntityTypeComponent          = "component"
	EntityTypeParent             = "parent"
	EntityTypeSelfOrParent       = "selfOrParent"
	EntityTypeSelfOrParentSymbol = "^"
	EntityTypeChild              = "child"
	EntityTypeSelfOrChild        = "selfOrChild"
	EntityTypeAny                = "*"
)
View Source
const (
	BuildConfigDir = "cfg"
	BuildKitDir    = "kit"
	BuildPkiDir    = "pki"
	BuildBinDir    = "bin"
	BuildTmpDir    = "tmp"
)
View Source
const (
	SelectorTagPrefix = "."
	SelectorIdPrefix  = "#"
)
View Source
const Version = "0.4.0 (tw3n7ytw3n7y0n3)"

Variables

View Source
var CliInstanceId string

Functions

func ActiveInstanceId

func ActiveInstanceId() string

func ActiveInstancePath

func ActiveInstancePath() string

func AddBootstrapExtension

func AddBootstrapExtension(ext BootstrapExtension)

func AllocateDump

func AllocateDump(run string) string

func AllocateForensicScenario

func AllocateForensicScenario(run, scenario string) string

func Bootstrap

func Bootstrap() error

func BootstrapBindings

func BootstrapBindings() error

func BootstrapInstance

func BootstrapInstance() error

func BuildPath added in v0.4.0

func BuildPath() string

func ConfigBuild

func ConfigBuild() string

func ConfigDir added in v0.4.0

func ConfigDir() (string, error)

func CreateLabel

func CreateLabel(instanceId string, bindings map[string]string) error

func GetScopedEntityPath added in v0.4.0

func GetScopedEntityPath(entity Entity) []string

func HomeDir added in v0.4.0

func HomeDir() string

func InitModel added in v0.4.0

func InitModel(m *Model)

func KitBuild

func KitBuild() string

func ListDumps

func ListDumps() ([]string, error)

func MakeBuildPath added in v0.4.0

func MakeBuildPath(path string) string

func NewInstance

func NewInstance(id, workingDirectory, executable string) (string, error)

func PersistConfig added in v0.4.0

func PersistConfig(config *FablabConfig) error

func PkiBuild

func PkiBuild() string

func ScriptBuild

func ScriptBuild() string

func Selector

func Selector(levels ...string) string

func SetActiveInstance

func SetActiveInstance(newInstanceId string) error

func UserInstanceRoot added in v0.5.1

func UserInstanceRoot() string

Types

type Action

type Action interface {
	Execute(run Run) error
}

type ActionBinder

type ActionBinder func(m *Model) Action

func Bind added in v0.4.1

func Bind(action Action) ActionBinder

type ActionBinders

type ActionBinders map[string]ActionBinder

type ActionFunc

type ActionFunc func(run Run) error

func (ActionFunc) Execute

func (f ActionFunc) Execute(run Run) error

type ActionsComponent added in v0.5.0

type ActionsComponent interface {
	ComponentType

	// GetActions returns the set of additional actions available on the component
	GetActions() map[string]ComponentAction
}

An ActionsComponent provides additional actions which can be executed using the ExecuteAction method

type BootstrapExtension

type BootstrapExtension interface {
	Bootstrap(m *Model) error
}

type CachingVariableResolver added in v0.4.0

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

func NewCachingVariableResolver added in v0.4.0

func NewCachingVariableResolver(resolver VariableResolver) *CachingVariableResolver

func (*CachingVariableResolver) Resolve added in v0.4.0

func (self *CachingVariableResolver) Resolve(entity Entity, name string, scoped bool) (interface{}, bool)

type ChainedVariableResolver added in v0.4.0

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

func (*ChainedVariableResolver) AppendResolver added in v0.4.0

func (self *ChainedVariableResolver) AppendResolver(resolver VariableResolver)

func (*ChainedVariableResolver) Resolve added in v0.4.0

func (self *ChainedVariableResolver) Resolve(entity Entity, name string, scoped bool) (interface{}, bool)

type CmdLineArgVariableResolver added in v0.4.0

type CmdLineArgVariableResolver struct{}

func (CmdLineArgVariableResolver) Resolve added in v0.4.0

func (self CmdLineArgVariableResolver) Resolve(entity Entity, name string, _ bool) (interface{}, bool)

type Component

type Component struct {
	Scope
	Id         string
	Host       *Host
	Type       ComponentType
	Index      uint32
	ScaleIndex uint32
	// contains filtered or unexported fields
}

func (*Component) Accept

func (component *Component) Accept(visitor EntityVisitor)

func (*Component) CloneComponent added in v0.4.1

func (component *Component) CloneComponent(scaleIndex uint32) *Component

func (*Component) GetActions added in v0.5.0

func (component *Component) GetActions() map[string]ComponentAction

func (*Component) GetChildren

func (component *Component) GetChildren() []Entity

func (*Component) GetHost

func (component *Component) GetHost() *Host

func (*Component) GetId

func (component *Component) GetId() string

func (*Component) GetModel

func (component *Component) GetModel() *Model

func (*Component) GetParentEntity

func (component *Component) GetParentEntity() Entity

func (*Component) GetPath

func (component *Component) GetPath() string

func (*Component) GetPathId added in v0.4.1

func (component *Component) GetPathId() string

func (*Component) GetRegion

func (component *Component) GetRegion() *Region

func (*Component) GetScope

func (component *Component) GetScope() *Scope

func (*Component) GetType

func (component *Component) GetType() string

func (*Component) IsRunning added in v0.5.1

func (component *Component) IsRunning(run Run) (bool, error)

func (*Component) Matches

func (component *Component) Matches(entityType string, matcher EntityMatcher) bool

func (*Component) Region

func (component *Component) Region() *Region

type ComponentAction added in v0.5.0

type ComponentAction interface {
	Execute(r Run, c *Component) error
}

A ComponentAction is an action execute in the context of a specific component

type ComponentActionF added in v0.5.0

type ComponentActionF func(r Run, c *Component) error

ComponentActionF is the function version of ComponentAction

func (ComponentActionF) Execute added in v0.5.0

func (f ComponentActionF) Execute(r Run, c *Component) error

type ComponentDump

type ComponentDump struct {
	Scope *ScopeDump `json:"scope,omitempty"`
	Type  any        `json:"type"`
}

type ComponentType added in v0.5.0

type ComponentType interface {
	// Label returns a short, user-friendly string describing the component typ
	Label() string

	// GetVersion returns the version of the component software
	GetVersion() string

	// Dump returns a JSON marshallable object allowing the strategy data to be dumped for inspection
	Dump() any

	// IsRunning returns true if the component is currently represented by a running process, false otherwise
	IsRunning(run Run, c *Component) (bool, error)

	// Stop will stop any currently running processes which represent the component
	Stop(run Run, c *Component) error
}

ComponentType contains the custom logic for a component. This can range from provisioning to configuration to running

type Components

type Components map[string]*Component

type CpuTimeslice

type CpuTimeslice struct {
	TimestampMs   int64   `json:"timestamp_ms"`
	PercentUser   float64 `json:"percent_user"`
	PercentNice   float64 `json:"percent_nice"`
	PercentSystem float64 `json:"percent_system"`
	PercentIowait float64 `json:"percent_iowait"`
	PercentSteal  float64 `json:"percent_steal"`
	PercentIdle   float64 `json:"percent_idle"`
}

type Data

type Data map[string]interface{}

type DataMetricsWriter

type DataMetricsWriter struct {
}

func (DataMetricsWriter) AcceptHostMetrics

func (DataMetricsWriter) AcceptHostMetrics(host *Host, event *MetricsEvent)

type DefaultScaleEntityFactory added in v0.4.1

type DefaultScaleEntityFactory struct{}

func (DefaultScaleEntityFactory) CreateScaledComponent added in v0.4.1

func (self DefaultScaleEntityFactory) CreateScaledComponent(source *Component, scaleIndex uint32) (*Component, error)

func (DefaultScaleEntityFactory) CreateScaledHost added in v0.4.1

func (self DefaultScaleEntityFactory) CreateScaledHost(source *Host, scaleIndex uint32) (*Host, error)

func (DefaultScaleEntityFactory) CreateScaledRegion added in v0.4.1

func (self DefaultScaleEntityFactory) CreateScaledRegion(source *Region, scaleIndex uint32) (*Region, error)

type Dump

type Dump struct {
	Scope   *ScopeDump             `json:"scope,omitempty"`
	Regions map[string]*RegionDump `json:"regions"`
}

type EC2Host added in v0.5.48

type EC2Host struct {
	Volume EC2Volume
}

type EC2Volume added in v0.5.48

type EC2Volume struct {
	Type   string
	SizeGB uint32
	IOPS   uint32
}

type Entity

type Entity interface {
	GetModel() *Model
	GetType() string
	GetId() string
	GetScope() *Scope
	GetParentEntity() Entity
	Accept(EntityVisitor)
	GetChildren() []Entity
	Matches(entityType string, matcher EntityMatcher) bool

	GetVariable(name string) (interface{}, bool)
	GetVariableOr(name string, defaultValue interface{}) interface{}
	MustVariable(name string) interface{}
}

type EntityMatcher

type EntityMatcher func(Entity) bool

func (EntityMatcher) And

func (EntityMatcher) Or

type EntityVisitor

type EntityVisitor func(Entity)

type EnvVariableResolver added in v0.4.0

type EnvVariableResolver struct{}

func (EnvVariableResolver) Resolve added in v0.4.0

func (self EnvVariableResolver) Resolve(entity Entity, name string, _ bool) (interface{}, bool)

type FablabConfig added in v0.4.0

type FablabConfig struct {
	Instances  map[string]*InstanceConfig `yaml:"instances"`
	Default    string                     `yaml:"default"`
	ConfigPath string                     `yaml:"-"`
}

func GetConfig added in v0.4.0

func GetConfig() *FablabConfig

func LoadConfig added in v0.5.1

func LoadConfig(configFile string) (*FablabConfig, error)

func (*FablabConfig) GetSelectedInstanceId added in v0.4.0

func (self *FablabConfig) GetSelectedInstanceId() string

type Factory

type Factory interface {
	Build(m *Model) error
}

Factory builds model instances.

type FactoryFunc added in v0.4.52

type FactoryFunc func(m *Model) error

func (FactoryFunc) Build added in v0.4.52

func (f FactoryFunc) Build(m *Model) error

type FileStagingComponent added in v0.5.0

type FileStagingComponent interface {
	ComponentType

	// StageFiles is called at the beginning of the configuration phase and allows the component to contribute
	// files to be synced to the Host
	StageFiles(r Run, c *Component) error
}

A FileStagingComponent is able to contribute files to the staging area, to be synced up to the components host. This may include things like binaries, scripts, configuration files and PKI.

type HierarchicalVariableResolver added in v0.4.0

type HierarchicalVariableResolver struct{}

func (HierarchicalVariableResolver) Resolve added in v0.4.0

func (self HierarchicalVariableResolver) Resolve(entity Entity, name string, scoped bool) (interface{}, bool)

type Host

type Host struct {
	Scope
	Id                   string
	EC2                  EC2Host
	Region               *Region
	PublicIp             string
	PrivateIp            string
	InstanceType         string
	InstanceResourceType string
	SpotPrice            string
	SpotType             string
	Components           Components
	Index                uint32
	ScaleIndex           uint32
	// contains filtered or unexported fields
}

func (*Host) Accept

func (host *Host) Accept(visitor EntityVisitor)

func (*Host) CloneHost added in v0.4.1

func (host *Host) CloneHost(scaleIndex uint32) *Host

func (*Host) DoExclusive added in v0.5.20

func (host *Host) DoExclusive(f func())

func (*Host) DoExclusiveFallible added in v0.5.20

func (host *Host) DoExclusiveFallible(f func() error) error

func (*Host) Exec added in v0.5.20

func (host *Host) Exec(out io.Writer, cmds ...string) error

func (*Host) ExecLogOnlyOnError added in v0.5.20

func (host *Host) ExecLogOnlyOnError(cmds ...string) error

func (*Host) ExecLogged added in v0.5.20

func (host *Host) ExecLogged(cmds ...string) (string, error)

func (*Host) ExecLoggedWithTimeout added in v0.5.55

func (host *Host) ExecLoggedWithTimeout(timeout time.Duration, cmds ...string) (string, error)

func (*Host) FindProcesses added in v0.5.20

func (host *Host) FindProcesses(filter func(string) bool) ([]int, error)

func (*Host) GetChildren

func (host *Host) GetChildren() []Entity

func (*Host) GetId

func (host *Host) GetId() string

func (*Host) GetModel

func (host *Host) GetModel() *Model

func (*Host) GetParentEntity

func (host *Host) GetParentEntity() Entity

func (*Host) GetPath

func (host *Host) GetPath() string

func (*Host) GetRegion

func (host *Host) GetRegion() *Region

func (*Host) GetScope

func (host *Host) GetScope() *Scope

func (*Host) GetSshUser added in v0.5.20

func (host *Host) GetSshUser() string

func (*Host) GetType

func (host *Host) GetType() string

func (*Host) KillProcesses added in v0.5.20

func (host *Host) KillProcesses(signal string, filter func(string) bool) error

func (*Host) Matches

func (host *Host) Matches(entityType string, matcher EntityMatcher) bool

func (*Host) NewSshConfigFactory added in v0.5.20

func (host *Host) NewSshConfigFactory() *libssh.SshConfigFactoryImpl

func (*Host) RangeSortedComponents added in v0.4.1

func (host *Host) RangeSortedComponents(f func(id string, component *Component))

func (*Host) RemoveComponent added in v0.4.1

func (host *Host) RemoveComponent(component *Component)

func (*Host) SendData added in v0.5.20

func (host *Host) SendData(data []byte, remotePath string) error

func (*Host) SendFile added in v0.5.20

func (host *Host) SendFile(localPath string, remotePath string) error

type HostDump

type HostDump struct {
	Scope                *ScopeDump                `json:"scope,omitempty"`
	PublicIp             string                    `json:"public_ip,omitempty"`
	PrivateIp            string                    `json:"private_ip,omitempty"`
	InstanceType         string                    `json:"instance_type,omitempty"`
	InstanceResourceType string                    `json:"instance_resource_type,omitempty"`
	SpotPrice            string                    `json:"spot_price,omitempty"`
	SpotType             string                    `json:"spot_type,omitempty"`
	Components           map[string]*ComponentDump `json:"components,omitempty"`
}

func DumpHost

func DumpHost(h *Host) *HostDump

type HostInitializingComponent added in v0.5.0

type HostInitializingComponent interface {
	ComponentType

	// InitializeHost is called at the end of the distribution phase and allows the component to
	// make changes to Host configuration
	InitializeHost(r Run, c *Component) error
}

A HostInitializingComponent can run some one-time configuration on the host as part of the distibution/sync phase. This would include things like adjusting system configuration files on the host.

type HostSummary

type HostSummary struct {
	Cpu     []*CpuTimeslice     `json:"cpu,omitempty"`
	Memory  []*MemoryTimeslice  `json:"memory,omitempty"`
	Process []*ProcessTimeslice `json:"process,omitempty"`
}

func (*HostSummary) ToMetricsEvents

func (hs *HostSummary) ToMetricsEvents() (events []*MetricsEvent)

type Hosts

type Hosts map[string]*Host

type IdPool added in v0.4.1

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

func (*IdPool) GetNextId added in v0.4.1

func (self *IdPool) GetNextId() uint32

func (*IdPool) ReturnId added in v0.4.1

func (self *IdPool) ReturnId(id uint32)

type InitializingComponent added in v0.5.43

type InitializingComponent interface {
	ComponentType

	// Init needs to be called explicitly
	Init(r Run, c *Component) error
}

A InitializingComponent can run some configuration on the host as part of the activation phase. Init isn't called explicitly as it often has dependencies on other components. However, by implementing this interface, the action will be made available, without requiring explicit registration

type InitializingComponentType added in v0.5.5

type InitializingComponentType interface {
	ComponentType

	// InitType is called as part of model initialization. It can be used to set or validate type fields.
	// It will be called once for each component using the type
	InitType(c *Component)
}

An InitializingComponentType has a hook to allow it to be setup while the model is being initialized.

type InstanceConfig added in v0.4.0

type InstanceConfig struct {
	Id               string `yaml:"name"`
	Model            string `yaml:"model"`
	WorkingDirectory string `yaml:"working_directory"`
	Executable       string `yaml:"executable"`
}

func GetActiveInstanceConfig added in v0.4.0

func GetActiveInstanceConfig() *InstanceConfig

func (*InstanceConfig) CleanupWorkingDir added in v0.4.0

func (self *InstanceConfig) CleanupWorkingDir() error

func (*InstanceConfig) LoadLabel added in v0.4.0

func (self *InstanceConfig) LoadLabel() (*Label, error)

type InstanceState

type InstanceState int
const (
	Created InstanceState = iota
	Expressed
	Configured
	Distributed
	Activated
	Operating
	Disposed
)

func (InstanceState) String

func (instanceState InstanceState) String() string

type IperfSummary

type IperfSummary struct {
	Timeslices    []*IperfTimeslice `json:"timeslices"`
	Bytes         float64           `json:"bytes"`
	BitsPerSecond float64           `json:"bits_per_second"`
}

type IperfTimeslice

type IperfTimeslice struct {
	TimestampMs   int64   `json:"timestamp_ms"`
	BitsPerSecond float64 `json:"bits_per_second"`
}

type IperfUdpSummary

type IperfUdpSummary struct {
	Timeslices    []*IperfUdpTimeslice `json:"timeslices"`
	Bytes         float64              `json:"bytes"`
	BitsPerSecond float64              `json:"bits_per_second"`
	JitterMs      float64              `json:"jitter_ms"`
	LostPackets   float64              `json:"lost_packets"`
}

type IperfUdpTimeslice

type IperfUdpTimeslice struct {
	TimestampMs   int64   `json:"timestamp_ms"`
	BitsPerSecond float64 `json:"bits_per_second"`
	Packets       float64 `json:"packets"`
}

type Label

type Label struct {
	InstanceId string        `yaml:"id"`
	Model      string        `yaml:"model"`
	State      InstanceState `yaml:"state"`
	Bindings   Variables     `yaml:"bindings"`
	// contains filtered or unexported fields
}

func GetLabel

func GetLabel() *Label

func LoadLabel

func LoadLabel(path string) (*Label, error)

func (*Label) GetFilePath

func (label *Label) GetFilePath(fileName string) string

func (*Label) Save

func (label *Label) Save() error

func (*Label) SaveAtPath

func (label *Label) SaveAtPath(path string) error

type MapVariableResolver added in v0.4.0

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

func NewMapVariableResolver added in v0.4.0

func NewMapVariableResolver(context string, variables Variables) *MapVariableResolver

func (*MapVariableResolver) Resolve added in v0.4.0

func (self *MapVariableResolver) Resolve(entity Entity, name string, _ bool) (interface{}, bool)

func (*MapVariableResolver) UpdateVariables added in v0.4.0

func (self *MapVariableResolver) UpdateVariables(variables Variables)

type MemoryTimeslice

type MemoryTimeslice struct {
	TimestampMs   int64   `json:"timestamp_ms"`
	MemFreeK      int64   `json:"free_k"`
	AvailK        int64   `json:"avail_k"`
	UsedK         int64   `json:"used_k"`
	UsedPercent   float64 `json:"used_percent"`
	BuffersK      int64   `json:"buffers_k"`
	CachedK       int64   `json:"cached_k"`
	CommitK       int64   `json:"commit_k"`
	CommitPercent float64 `json:"commit_percent"`
	ActiveK       int64   `json:"active_k"`
	InactiveK     int64   `json:"inactive_k"`
	DirtyK        int64   `json:"dirty_k"`
}

type MetricSet

type MetricSet map[string]interface{}

func (MetricSet) AddGroupedMetric

func (s MetricSet) AddGroupedMetric(group, name string, val interface{})

func (MetricSet) VisitGroupedMetrics

func (s MetricSet) VisitGroupedMetrics(f func(name string, group MetricSet))

func (MetricSet) VisitUngroupedMetrics

func (s MetricSet) VisitUngroupedMetrics(f func(name string, val interface{}))

type MetricsEvent

type MetricsEvent struct {
	Timestamp time.Time
	Metrics   MetricSet
	Tags      map[string]string
}

type MetricsHandler

type MetricsHandler interface {
	AcceptHostMetrics(host *Host, event *MetricsEvent)
}

type Model

type Model struct {
	Id string

	Scope
	VarConfig           VarConfig
	Regions             Regions
	StructureFactories  []Factory // Factories that change the model structure, eg: add/remove hosts
	Factories           []Factory
	BootstrapExtensions []BootstrapExtension
	Actions             map[string]ActionBinder
	Infrastructure      Stages
	Configuration       Stages
	Distribution        Stages
	Activation          Stages
	Operation           Stages
	Disposal            Stages
	MetricsHandlers     []MetricsHandler
	Resources           Resources
	// contains filtered or unexported fields
}

func GetModel

func GetModel() *Model

func (*Model) Accept

func (m *Model) Accept(visitor EntityVisitor)

func (*Model) AcceptHostMetrics

func (m *Model) AcceptHostMetrics(host *Host, event *MetricsEvent)

func (*Model) Activate

func (m *Model) Activate(run Run) error

func (*Model) AddActivationActions

func (m *Model) AddActivationActions(actions ...string)

func (*Model) AddActivationStage

func (m *Model) AddActivationStage(stage Stage)

func (*Model) AddActivationStages

func (m *Model) AddActivationStages(stage ...Stage)

func (*Model) AddOperatingActions

func (m *Model) AddOperatingActions(actions ...string)

func (*Model) AddOperatingStage

func (m *Model) AddOperatingStage(stage Stage)

func (*Model) AddOperatingStageF added in v0.4.0

func (m *Model) AddOperatingStageF(stage StageActionF)

func (*Model) AddOperatingStages

func (m *Model) AddOperatingStages(stages ...Stage)

func (*Model) BindLabel

func (m *Model) BindLabel(l *Label)

func (*Model) Build

func (m *Model) Build(run Run) error

func (*Model) Dispose

func (m *Model) Dispose(run Run) error

func (*Model) Dump

func (m *Model) Dump() *Dump

func (*Model) ExecuteAction added in v0.5.48

func (m *Model) ExecuteAction(actionName string) Action

func (*Model) Express

func (m *Model) Express(run Run) error

func (*Model) ForEachComponent

func (m *Model) ForEachComponent(spec string, concurrency int, f func(c *Component) error) error

func (*Model) ForEachComponentIn added in v0.5.38

func (m *Model) ForEachComponentIn(components []*Component, concurrency int, f func(c *Component) error) error

func (*Model) ForEachHost

func (m *Model) ForEachHost(spec string, concurrency int, f func(host *Host) error) error

func (*Model) GetAction

func (m *Model) GetAction(name string) (Action, bool)

func (*Model) GetActions added in v0.4.1

func (m *Model) GetActions() []string

func (*Model) GetChildren

func (m *Model) GetChildren() []Entity

func (*Model) GetId

func (m *Model) GetId() string

func (*Model) GetModel

func (m *Model) GetModel() *Model

func (*Model) GetNextComponentIndex added in v0.4.1

func (m *Model) GetNextComponentIndex() uint32

func (*Model) GetNextHostIndex added in v0.4.1

func (m *Model) GetNextHostIndex() uint32

func (*Model) GetNextRegionIndex added in v0.4.1

func (m *Model) GetNextRegionIndex() uint32

func (*Model) GetParentEntity

func (m *Model) GetParentEntity() Entity

func (*Model) GetResource added in v0.4.0

func (m *Model) GetResource(name string) fs.FS

func (*Model) GetScope

func (m *Model) GetScope() *Scope

func (*Model) GetType

func (m *Model) GetType() string

func (*Model) IsBound

func (m *Model) IsBound() bool

func (*Model) IterateScopes

func (m *Model) IterateScopes(f func(i Entity, path ...string))

func (*Model) Matches

func (m *Model) Matches(entityType string, matcher EntityMatcher) bool

func (*Model) MustSelectHost

func (m *Model) MustSelectHost(spec string) *Host

func (*Model) MustSelectHosts

func (m *Model) MustSelectHosts(spec string, minCount int) ([]*Host, error)

func (*Model) MustSelectRegion

func (m *Model) MustSelectRegion(spec string) *Region

func (*Model) Operate

func (m *Model) Operate(run Run) error

func (*Model) RangeSortedRegions added in v0.4.1

func (m *Model) RangeSortedRegions(f func(id string, region *Region))

func (*Model) RemoveRegion added in v0.4.1

func (m *Model) RemoveRegion(region *Region)

func (*Model) SelectComponent

func (m *Model) SelectComponent(spec string) (*Component, error)

func (*Model) SelectComponents

func (m *Model) SelectComponents(spec string) []*Component

func (*Model) SelectHost

func (m *Model) SelectHost(spec string) (*Host, error)

func (*Model) SelectHosts

func (m *Model) SelectHosts(spec string) []*Host

func (*Model) SelectRegion

func (m *Model) SelectRegion(spec string) (*Region, error)

func (*Model) SelectRegions

func (m *Model) SelectRegions(spec string) []*Region

func (*Model) Sync

func (m *Model) Sync(run Run) error

type ProcessTimeslice

type ProcessTimeslice struct {
	TimestampMs     int64   `json:"timestamp_ms"`
	RunQueueSize    int64   `json:"run_queue_size"`
	ProcessListSize int64   `json:"process_list_size"`
	LoadAverage1m   float64 `json:"load_average_1m"`
	LoadAverage5m   float64 `json:"load_average_5m"`
	LoadAverage15m  float64 `json:"load_average_15m"`
	Blocked         int64   `json:"blocked"`
}

type Region

type Region struct {
	Scope
	Model      *Model
	Id         string
	Region     string
	Site       string
	Hosts      Hosts
	Index      uint32
	ScaleIndex uint32
	// contains filtered or unexported fields
}

func (*Region) Accept

func (region *Region) Accept(visitor EntityVisitor)

func (*Region) CloneRegion added in v0.4.1

func (region *Region) CloneRegion(scaleIndex uint32) *Region

func (*Region) GetChildren

func (region *Region) GetChildren() []Entity

func (*Region) GetId

func (region *Region) GetId() string

func (*Region) GetModel

func (region *Region) GetModel() *Model

func (*Region) GetParentEntity

func (region *Region) GetParentEntity() Entity

func (*Region) GetScope

func (region *Region) GetScope() *Scope

func (*Region) GetType

func (region *Region) GetType() string

func (*Region) Matches

func (region *Region) Matches(entityType string, matcher EntityMatcher) bool

func (*Region) RangeSortedHosts added in v0.4.1

func (region *Region) RangeSortedHosts(f func(id string, host *Host))

func (*Region) RemoveHost added in v0.4.1

func (region *Region) RemoveHost(host *Host)

func (*Region) SelectHosts

func (region *Region) SelectHosts(hostSpec string) map[string]*Host

type RegionDump

type RegionDump struct {
	Scope *ScopeDump           `json:"scope,omitempty"`
	Id    string               `json:"id,omitempty"`
	Az    string               `json:"az,omitempty"`
	Hosts map[string]*HostDump `json:"hosts,omitempty"`
}

type Regions

type Regions map[string]*Region

type Resource added in v0.4.0

type Resource fs.FS

type Resources added in v0.4.0

type Resources map[string]Resource

type Run

type Run interface {
	StagingArea
	GetModel() *Model
	GetLabel() *Label
	GetId() string
}

func NewRun

func NewRun() (Run, error)

type ScaleEntityFactory added in v0.4.1

type ScaleEntityFactory interface {
	CreateScaledRegion(source *Region, scaleIndex uint32) (*Region, error)
	CreateScaledHost(source *Host, scaleIndex uint32) (*Host, error)
	CreateScaledComponent(source *Component, scaleIndex uint32) (*Component, error)
}

type ScaleFactory added in v0.4.1

type ScaleFactory struct {
	Strategy      ScaleStrategy
	EntityFactory ScaleEntityFactory
}

func NewScaleFactory added in v0.4.1

func NewScaleFactory(strategy ScaleStrategy, factory ScaleEntityFactory) *ScaleFactory

func NewScaleFactoryWithDefaultEntityFactory added in v0.4.1

func NewScaleFactoryWithDefaultEntityFactory(strategy ScaleStrategy) *ScaleFactory

func (*ScaleFactory) Build added in v0.4.1

func (factory *ScaleFactory) Build(m *Model) error

func (*ScaleFactory) ProcessComponents added in v0.4.1

func (factory *ScaleFactory) ProcessComponents(m *Model) error

func (*ScaleFactory) ProcessHosts added in v0.4.1

func (factory *ScaleFactory) ProcessHosts(m *Model) error

func (*ScaleFactory) ProcessRegions added in v0.4.1

func (factory *ScaleFactory) ProcessRegions(m *Model) error

type ScaleStrategy added in v0.4.1

type ScaleStrategy interface {
	IsScaled(entity Entity) bool
	GetEntityCount(entity Entity) uint32
}

type Scope

type Scope struct {
	Defaults         Variables
	VariableResolver VariableResolver
	Data             Data
	Tags             Tags
	// contains filtered or unexported fields
}

func (*Scope) CloneScope added in v0.4.1

func (scope *Scope) CloneScope() *Scope

func (*Scope) GetBoolVariable added in v0.4.0

func (scope *Scope) GetBoolVariable(name string) (bool, bool)

func (*Scope) GetFlag added in v0.5.12

func (scope *Scope) GetFlag(name string) bool

func (*Scope) GetRequiredStringVariable added in v0.4.0

func (scope *Scope) GetRequiredStringVariable(holder errorz.ErrorHolder, name string) string

func (*Scope) GetStringVariable added in v0.4.0

func (scope *Scope) GetStringVariable(name string) (string, bool)

func (*Scope) GetStringVariableOr added in v0.4.0

func (scope *Scope) GetStringVariableOr(name string, defaultValue string) string

func (*Scope) GetVariable added in v0.4.0

func (scope *Scope) GetVariable(name string) (interface{}, bool)

func (*Scope) GetVariableOr added in v0.4.0

func (scope *Scope) GetVariableOr(name string, defaultValue interface{}) interface{}

func (*Scope) HasLocalOrAncestralTag added in v0.4.1

func (scope *Scope) HasLocalOrAncestralTag(tag string) bool

func (*Scope) HasTag

func (scope *Scope) HasTag(tag string) bool

func (*Scope) HasVariable added in v0.4.0

func (scope *Scope) HasVariable(name string) bool

func (*Scope) MustStringVariable added in v0.4.0

func (scope *Scope) MustStringVariable(name string) string

func (*Scope) MustVariable added in v0.4.0

func (scope *Scope) MustVariable(name string) interface{}

func (*Scope) PutVariable added in v0.4.0

func (scope *Scope) PutVariable(name string, value interface{})

func (*Scope) WithTags

func (scope *Scope) WithTags(tags ...string) *Scope

type ScopeDump

type ScopeDump struct {
	Variables map[string]interface{} `json:"variables,omitempty"`
	Data      map[string]interface{} `json:"data,omitempty"`
	Tags      []string               `json:"tags,omitempty"`
}

type ScopedVariableResolver added in v0.4.0

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

func NewScopedVariableResolver added in v0.4.0

func NewScopedVariableResolver(resolver VariableResolver) *ScopedVariableResolver

func (*ScopedVariableResolver) Resolve added in v0.4.0

func (self *ScopedVariableResolver) Resolve(entity Entity, name string, scoped bool) (interface{}, bool)

type ServerComponent added in v0.5.0

type ServerComponent interface {
	Start(run Run, c *Component) error
}

A ServerComponent is one which can be started and left running in the background

type Stage added in v0.5.0

type Stage interface {
	Execute(run Run) error
}

type StageActionF added in v0.5.0

type StageActionF func(run Run) error

func (StageActionF) Execute added in v0.5.0

func (self StageActionF) Execute(run Run) error

type Stages added in v0.5.0

type Stages []Stage

type StagingArea added in v0.5.0

type StagingArea interface {
	GetWorkingDir() string
	GetConfigDir() string
	GetPkiDir() string
	GetBinDir() string
	GetTmpDir() string

	DirExists(path string) (bool, error)
	FileExists(path string) (bool, error)

	DoOnce(operation string, f func() error) error
}

type StdOutMetricsWriter

type StdOutMetricsWriter struct {
}

func (StdOutMetricsWriter) AcceptHostMetrics

func (StdOutMetricsWriter) AcceptHostMetrics(host *Host, event *MetricsEvent)

type Tags

type Tags []string

type Templater added in v0.4.1

type Templater struct {
	errorz.ErrorHolderImpl
	// contains filtered or unexported fields
}

func (*Templater) TemplatizeComponent added in v0.4.1

func (self *Templater) TemplatizeComponent(component *Component)

func (*Templater) TemplatizeHost added in v0.4.1

func (self *Templater) TemplatizeHost(host *Host)

func (*Templater) TemplatizeRegion added in v0.4.1

func (self *Templater) TemplatizeRegion(region *Region)

func (*Templater) TemplatizeScope added in v0.4.1

func (self *Templater) TemplatizeScope(scope *Scope)

func (*Templater) TemplatizeString added in v0.4.1

func (self *Templater) TemplatizeString(val string) string

type VarConfig added in v0.4.0

type VarConfig struct {
	VariableNameParser            VariableNameParser
	CommandLineVariableNameMapper VariableNameMapper
	CommandLinePrefixes           []string
	EnvVariableNameMapper         VariableNameMapper
	DefaultVariableResolver       VariableResolver
	DefaultScopedVariableResolver VariableResolver
	SecretsKeys                   []string
	VariableNamePrefixMapper      VariableNamePrefixMapper
	ResolverLogger                func(resolver string, entity Entity, name string, result interface{}, found bool, msgAndArgs ...interface{})
	BindingResolver               *MapVariableResolver
	LabelResolver                 *MapVariableResolver
}

func (*VarConfig) EnableDebugLogger added in v0.4.0

func (self *VarConfig) EnableDebugLogger()

func (*VarConfig) SetDefaults added in v0.4.0

func (self *VarConfig) SetDefaults()

type VariableDump

type VariableDump struct {
	Description    string `json:"description,omitempty"`
	Default        string `json:"default,omitempty"`
	Required       bool   `json:"required"`
	Scoped         bool   `json:"scoped"`
	GlobalFallback bool   `json:"global_fallback"`
	Sensitive      bool   `json:"sensitive"`
	Binder         string `json:"binder,omitempty"`
	Value          string `json:"value,omitempty"`
	Bound          bool   `json:"bound"`
}

type VariableNameMapper added in v0.4.0

type VariableNameMapper func(string) string

type VariableNameParser added in v0.4.0

type VariableNameParser func(string) []string

type VariableNamePrefixMapper added in v0.4.0

type VariableNamePrefixMapper func(entityPath []string, name string) string

type VariableResolver added in v0.4.0

type VariableResolver interface {
	Resolve(entity Entity, name string, scoped bool) (interface{}, bool)
}

type Variables

type Variables map[string]interface{}

func (Variables) Canonicalize added in v0.4.0

func (v Variables) Canonicalize()

func (Variables) Clone added in v0.4.1

func (v Variables) Clone() Variables

func (Variables) ForEach added in v0.4.1

func (v Variables) ForEach(f func(k string, v interface{}) (bool, interface{}))

func (Variables) Get

func (v Variables) Get(name []string) (interface{}, bool)

func (Variables) Put

func (v Variables) Put(name []string, newValue interface{})

type ZitiFabricLinkMetricsSummary

type ZitiFabricLinkMetricsSummary struct {
	LinkId        string  `json:"link_id"`
	LatencyP9999  float64 `json:"latency_p9999"`
	RxBytesRateM1 float64 `json:"rx_bytes_rate_m1"`
	TxBytesRateM1 float64 `json:"tx_bytes_rate_m1"`
}

type ZitiFabricLinkSummary

type ZitiFabricLinkSummary struct {
	LinkId      string  `json:"link_id"`
	State       string  `json:"state"`
	SrcRouterId string  `json:"src_router_id"`
	SrcLatency  float64 `json:"src_latency"`
	DstRouterId string  `json:"dst_router_id"`
	DstLatency  float64 `json:"dst_latency"`
}

type ZitiFabricMeshSummary

type ZitiFabricMeshSummary struct {
	TimestampMs int64                   `json:"timestamp_ms"`
	RouterIds   []string                `json:"router_ids"`
	Links       []ZitiFabricLinkSummary `json:"links,omitempty"`
}

type ZitiFabricRouterMetricsSummary

type ZitiFabricRouterMetricsSummary struct {
	SourceId             string                         `json:"source_id"`
	TimestampMs          int64                          `json:"timestamp_ms"`
	FabricRxBytesRateM1  float64                        `json:"fabric_rx_bytes_rate_m1"`
	FabricTxBytesRateM1  float64                        `json:"fabric_tx_bytes_rate_m1"`
	IngressRxBytesRateM1 float64                        `json:"ingress_rx_bytes_rate_m1"`
	IngressTxBytesRateM1 float64                        `json:"ingress_tx_bytes_rate_m1"`
	EgressRxBytesRateM1  float64                        `json:"egress_rx_bytes_rate_m1"`
	EgressTxBytesRateM1  float64                        `json:"egress_tx_bytes_rate_m1"`
	Links                []ZitiFabricLinkMetricsSummary `json:"links,omitempty"`
}

Jump to

Keyboard shortcuts

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