store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package store provides a way for the apatelet to have state

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlagGetter

type FlagGetter interface {
	// GetNodeFlag returns the value of the given node flag
	GetNodeFlag(events.NodeEventFlag) (interface{}, error)

	// GetPodFlag returns the value of the given pod for a configuration
	GetPodFlag(*corev1.Pod, events.PodEventFlag) (interface{}, error)
}

FlagGetter defines function aiding in retrieving flags

type FlagSetter

type FlagSetter interface {
	// SetNodeFlag sets the value of the given node flag
	SetNodeFlags(Flags)

	// SetNodeFlag sets the value of the given pod flag for a configuration
	SetPodFlags(string, Flags)

	// SetNodeFlag sets the value of the given pod flag for a configuration
	SetPodTimeFlags(string, []*TimeFlags)
}

FlagSetter defines function aiding in setting flags

type Flags

type Flags map[events.EventFlag]interface{}

Flags is a map from event flags to their interface value

type NodeTask

type NodeTask struct {
	State *nodeconfigv1.NodeConfigurationState
}

NodeTask is a task that should be executed on a node level

type PodTask

type PodTask struct {
	// The label of the CRD, should be <namespace>/<name>
	Label string
	State *podconfigv1.PodConfigurationState
}

PodTask is a task that should be executed on a pod level

type Store

type Store interface {
	TaskSetter
	FlagSetter
	FlagGetter

	// RemovePodTasks removes pod CRD tasks from the queue based on their label (<namespace>/<name>)
	RemovePodTasks(string) error

	// PeekTask returns the start time of the next task in the priority queue, without removing it from the queue
	PeekTask() (time.Duration, bool, error)

	// PopTask returns the first task to be executed and removes it from the queue
	PopTask() (*Task, error)

	// AddPodFlagListener adds a listener which is called when the given flag is updated
	AddPodFlagListener(events.PodEventFlag, func(interface{}))
}

Store represents the state of the apatelet

func NewStore

func NewStore() Store

NewStore returns an empty store

type Task

type Task struct {
	// The timestamp on which this task should be executed, relative to the start of the scenario
	RelativeTimestamp time.Duration

	PodTask  *PodTask
	NodeTask *NodeTask
}

Task is a task in the PQ

func NewNodeTask

func NewNodeTask(relativeTime time.Duration, state *nodeconfigv1.NodeConfigurationState) *Task

NewNodeTask creates a new task for a node event

func NewPodTask

func NewPodTask(relativeTime time.Duration, label string, state *podconfigv1.PodConfigurationState) *Task

NewPodTask creates a new task for a pod event

func (*Task) IsNode

func (t *Task) IsNode() (bool, error)

IsNode returns true if the task is a node task

func (*Task) IsPod

func (t *Task) IsPod() (bool, error)

IsPod returns whether we are dealing with a pod (then PodTask should be non-nil) or a node (then NodeTask should be non-nil)

type TaskSetter

type TaskSetter interface {
	// SetNodeTasks adds or updates node tasks
	// Existing node tasks will be removed if not in the list of tasks
	SetNodeTasks([]*Task) error

	// SetPodTasks adds or updates pod CRD tasks to the queue based on their label (<namespace>/<name>)
	// Existing pod tasks will be removed if not in the list of tasks
	SetPodTasks(string, []*Task) error
}

TaskSetter defines function aiding in setting tasks

type TaskTypeCheck

type TaskTypeCheck func(*Task) (bool, error)

TaskTypeCheck is function which is able to determine if the given task is of a certain type

type TimeFlags

type TimeFlags struct {
	TimeSincePodStart time.Duration
	Flags             Flags
}

TimeFlags contains Flags at a certain timestamp relative to the starting time of a pod

Directories

Path Synopsis
Package mock_store is a generated GoMock package.
Package mock_store is a generated GoMock package.

Jump to

Keyboard shortcuts

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