registry

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: Apache-2.0 Imports: 19 Imported by: 3

Documentation

Overview

Need to start DRYing up the registry code, this is terrible

Index

Constants

View Source
const (
	EventDirectory                 string        = "milpa/events/"
	EventDirectoryPlaceholder      string        = "milpa/events/."
	EventTrashDirectory            string        = "milpa/trash/events/"
	EventTrashDirectoryPlaceholder string        = "milpa/trash/events/."
	DefaultTTL                     time.Duration = 1 * time.Hour
)
View Source
const (
	LogDirectory            string        = "milpa/logs"
	LogDirectoryPlaceholder string        = "milpa/logs/."
	DefaultLogTTL           time.Duration = 1 * time.Hour
)
View Source
const (
	NodePath                      string = "milpa/nodes"
	NodeTrashPath                 string = "milpa/trash/nodes"
	NodeDirectoryPlaceholder      string = "milpa/nodes/."
	NodeTrashDirectoryPlaceholder string = "milpa/trash/nodes/."
)
View Source
const (
	PodPath                      string = "milpa/pods"
	PodTrashPath                 string = "milpa/trash/pods"
	PodDirectoryPlaceholder      string = "milpa/pods/."
	PodTrashDirectoryPlaceholder string = "milpa/trash/pods/."
)
View Source
const MilpaRoot = "milpa/"

Variables

View Source
var (
	ErrAlreadyExists = errors.New("Object already exists")
)

Functions

func CreateKVStore

func CreateKVStore(filename string) etcd.Storer

func MatchAllEvents

func MatchAllEvents(e *api.Event) bool

func MatchAllLivePods

func MatchAllLivePods(p *api.Pod) bool

func MatchAllNodes

func MatchAllNodes(p *api.Node) bool

func MatchAllPods

func MatchAllPods(p *api.Pod) bool

Types

type EventRegistry

type EventRegistry struct {
	etcd.Storer
	// contains filtered or unexported fields
}

func NewEventRegistry

func NewEventRegistry(kvstore etcd.Storer, codec api.MilpaCodec, es *events.EventSystem) *EventRegistry

func SetupTestEventRegistry

func SetupTestEventRegistry() (*EventRegistry, func())

func (*EventRegistry) Create

func (reg *EventRegistry) Create(obj api.MilpaObject) (api.MilpaObject, error)

func (*EventRegistry) CreateEvent

func (reg *EventRegistry) CreateEvent(e *api.Event) (*api.Event, error)

func (*EventRegistry) Delete

func (reg *EventRegistry) Delete(name string) (api.MilpaObject, error)

func (*EventRegistry) DeleteEvent

func (reg *EventRegistry) DeleteEvent(e *api.Event) (*api.Event, error)

func (*EventRegistry) Get

func (reg *EventRegistry) Get(name string) (api.MilpaObject, error)

func (*EventRegistry) GetEvent

func (reg *EventRegistry) GetEvent(obj *api.ObjectReference, name string) (*api.Event, error)

func (*EventRegistry) Handle

func (reg *EventRegistry) Handle(e events.Event) error

func (*EventRegistry) List

func (reg *EventRegistry) List() (api.MilpaObject, error)

func (*EventRegistry) ListEvents

func (reg *EventRegistry) ListEvents(filter func(*api.Event) bool) (*api.EventList, error)

func (*EventRegistry) ListEventsByObject

func (reg *EventRegistry) ListEventsByObject(obj *api.ObjectReference) (*api.EventList, error)

func (*EventRegistry) ListEventsWithPrefix

func (reg *EventRegistry) ListEventsWithPrefix(prefix string, filter func(*api.Event) bool) (*api.EventList, error)

func (*EventRegistry) New

func (reg *EventRegistry) New() api.MilpaObject

func (*EventRegistry) Update

func (reg *EventRegistry) Update(obj api.MilpaObject) (api.MilpaObject, error)

type LogRegistry

type LogRegistry struct {
	etcd.Storer
	// contains filtered or unexported fields
}

func NewLogRegistry

func NewLogRegistry(kvstore etcd.Storer, codec api.MilpaCodec, es *events.EventSystem) *LogRegistry

func SetupTestLogRegistry

func SetupTestLogRegistry() (*LogRegistry, func())

func (*LogRegistry) Create

func (reg *LogRegistry) Create(obj api.MilpaObject) (api.MilpaObject, error)

func (*LogRegistry) CreateLog

func (reg *LogRegistry) CreateLog(log *api.LogFile) (*api.LogFile, error)

func (*LogRegistry) Delete

func (reg *LogRegistry) Delete(fullPath string) (api.MilpaObject, error)

func (*LogRegistry) Get

func (reg *LogRegistry) Get(compoundName string) (api.MilpaObject, error)

func (*LogRegistry) GetLog

func (reg *LogRegistry) GetLog(creatorName, logName string) (*api.LogFile, error)

func (*LogRegistry) List

func (reg *LogRegistry) List() (api.MilpaObject, error)

func (*LogRegistry) ListLogs

func (reg *LogRegistry) ListLogs(creatorName, logName string) (*api.LogFileList, error)

func (*LogRegistry) New

func (reg *LogRegistry) New() api.MilpaObject

func (*LogRegistry) PutLog

func (reg *LogRegistry) PutLog(log *api.LogFile) (*api.LogFile, error)

Create or overwrite the log, No updates at this time

func (*LogRegistry) Update

func (reg *LogRegistry) Update(obj api.MilpaObject) (api.MilpaObject, error)

type MetricsRegistry

type MetricsRegistry struct {
	MetricsStore
}

func NewMetricsRegistry

func NewMetricsRegistry(numDatapoints int) *MetricsRegistry

func (*MetricsRegistry) Create

func (reg *MetricsRegistry) Create(obj api.MilpaObject) (api.MilpaObject, error)

func (*MetricsRegistry) Delete

func (reg *MetricsRegistry) Delete(name string) (api.MilpaObject, error)

func (*MetricsRegistry) Get

func (reg *MetricsRegistry) Get(name string) (api.MilpaObject, error)

func (*MetricsRegistry) List

func (reg *MetricsRegistry) List() (api.MilpaObject, error)

func (*MetricsRegistry) New

func (reg *MetricsRegistry) New() api.MilpaObject

func (*MetricsRegistry) Update

func (reg *MetricsRegistry) Update(obj api.MilpaObject) (api.MilpaObject, error)

type MetricsStore

type MetricsStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewMetricsStore

func NewMetricsStore(numDatapoints int) *MetricsStore

func (*MetricsStore) DeletePods

func (m *MetricsStore) DeletePods(podNames ...string)

func (*MetricsStore) GetLatestMetrics

func (m *MetricsStore) GetLatestMetrics() *api.MetricsList

get the most recent metrics from all pods

func (*MetricsStore) GetPodMetrics

func (m *MetricsStore) GetPodMetrics(podName string) *api.MetricsList

Get all the metrics for a pod Todo: update this to return not found

func (*MetricsStore) Insert

func (m *MetricsStore) Insert(podName string, t api.Time, r api.ResourceMetrics)

todo: fix this to take a pointer to a metric and calculate the window lightweight: t, ResourceMetrics

func (*MetricsStore) ListPods

func (m *MetricsStore) ListPods() []string

type NodeLister

type NodeLister interface {
	GetNode(string) (*api.Node, error)
	ListNodes(func(*api.Node) bool) (*api.NodeList, error)
}

type NodeRegistry

type NodeRegistry struct {
	etcd.Storer
	Codec api.MilpaCodec
	// contains filtered or unexported fields
}

func NewNodeRegistry

func NewNodeRegistry(kvstore etcd.Storer, codec api.MilpaCodec, es *events.EventSystem) *NodeRegistry

func SetupTestNodeRegistry

func SetupTestNodeRegistry() (*NodeRegistry, func())

func (*NodeRegistry) AtomicUpdate

func (reg *NodeRegistry) AtomicUpdate(id string, modifier modifyNodeFunc) (*api.Node, error)

func (*NodeRegistry) Create

func (reg *NodeRegistry) Create(obj api.MilpaObject) (api.MilpaObject, error)

func (*NodeRegistry) CreateNode

func (reg *NodeRegistry) CreateNode(n *api.Node) (*api.Node, error)

func (*NodeRegistry) Delete

func (reg *NodeRegistry) Delete(name string) (api.MilpaObject, error)

func (*NodeRegistry) Get

func (reg *NodeRegistry) Get(id string) (api.MilpaObject, error)

func (*NodeRegistry) GetNode

func (reg *NodeRegistry) GetNode(name string) (*api.Node, error)

func (*NodeRegistry) List

func (reg *NodeRegistry) List() (api.MilpaObject, error)

func (*NodeRegistry) ListAllNodes

func (reg *NodeRegistry) ListAllNodes(filter func(*api.Node) bool) (*api.NodeList, error)

This is a terrible function but is helpful for tests in the node controller it's possible listnodes should just do this functionality...

func (*NodeRegistry) ListNodes

func (reg *NodeRegistry) ListNodes(filter func(*api.Node) bool) (*api.NodeList, error)

func (*NodeRegistry) MarkForTermination

func (reg *NodeRegistry) MarkForTermination(node *api.Node) (*api.Node, error)

func (*NodeRegistry) New

func (reg *NodeRegistry) New() api.MilpaObject

func (*NodeRegistry) PurgeNode

func (reg *NodeRegistry) PurgeNode(node *api.Node) (*api.Node, error)

func (*NodeRegistry) SetNodeDeletionTimestamp

func (reg *NodeRegistry) SetNodeDeletionTimestamp(node *api.Node) (*api.Node, error)

func (*NodeRegistry) Update

func (reg *NodeRegistry) Update(obj api.MilpaObject) (api.MilpaObject, error)

func (*NodeRegistry) UpdateNode

func (reg *NodeRegistry) UpdateNode(n *api.Node) (*api.Node, error)

func (*NodeRegistry) UpdateStatus

func (reg *NodeRegistry) UpdateStatus(node *api.Node) (*api.Node, error)

func (*NodeRegistry) Validate

func (reg *NodeRegistry) Validate(obj api.MilpaObject) error

type PodLister

type PodLister interface {
	GetPod(string) (*api.Pod, error)
	ListPods(func(*api.Pod) bool) (*api.PodList, error)
}

These Lister Interfaces were added to enforce read only registries that prevent callers from modifying core objects they have no business messing with.

type PodMetrics

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

////////////////////////////////////////////////////////////////////

func NewPodMetrics

func NewPodMetrics(name string, numDatpoints int) *PodMetrics

type PodRegistry

type PodRegistry struct {
	etcd.Storer
	Codec api.MilpaCodec
	// contains filtered or unexported fields
}

func NewPodRegistry

func NewPodRegistry(kvstore etcd.Storer, codec api.MilpaCodec, es *events.EventSystem, sv *validation.StatefulValidator) *PodRegistry

func SetupTestPodRegistry

func SetupTestPodRegistry() (*PodRegistry, func())

func (*PodRegistry) AtomicUpdate

func (reg *PodRegistry) AtomicUpdate(name string, modifier modifyPodFunc) (*api.Pod, error)

func (*PodRegistry) Create

func (reg *PodRegistry) Create(obj api.MilpaObject) (api.MilpaObject, error)

func (*PodRegistry) CreatePod

func (reg *PodRegistry) CreatePod(p *api.Pod) (*api.Pod, error)

func (*PodRegistry) Delete

func (reg *PodRegistry) Delete(name string) (api.MilpaObject, error)

While this is called delete, that's simply because it's the handler for the milpactl call to "Delete". Really, it specifies that we should terminate this pod and then delete it

func (*PodRegistry) Get

func (reg *PodRegistry) Get(name string) (api.MilpaObject, error)

func (*PodRegistry) GetPod

func (reg *PodRegistry) GetPod(k string) (*api.Pod, error)

func (*PodRegistry) List

func (reg *PodRegistry) List() (api.MilpaObject, error)

func (*PodRegistry) ListPods

func (reg *PodRegistry) ListPods(filter func(*api.Pod) bool) (*api.PodList, error)

func (*PodRegistry) MarkPodForTermination

func (reg *PodRegistry) MarkPodForTermination(pod *api.Pod) (*api.Pod, error)

func (*PodRegistry) New

func (reg *PodRegistry) New() api.MilpaObject

func (*PodRegistry) TerminatePod

func (reg *PodRegistry) TerminatePod(pod *api.Pod, phase api.PodPhase, msg string) error

func (*PodRegistry) Update

func (reg *PodRegistry) Update(obj api.MilpaObject) (api.MilpaObject, error)

func (*PodRegistry) UpdatePodSpecAndLabels

func (reg *PodRegistry) UpdatePodSpecAndLabels(p *api.Pod) (*api.Pod, error)

func (*PodRegistry) UpdatePodStatus

func (reg *PodRegistry) UpdatePodStatus(p *api.Pod, reason string) (*api.Pod, error)

func (*PodRegistry) Validate

func (reg *PodRegistry) Validate(obj api.MilpaObject) error

type Registryer

type Registryer interface {
	New() api.MilpaObject
	Create(obj api.MilpaObject) (api.MilpaObject, error)
	Update(obj api.MilpaObject) (api.MilpaObject, error)
	Get(id string) (api.MilpaObject, error)
	List() (api.MilpaObject, error)
	Delete(id string) (api.MilpaObject, error)
}

Jump to

Keyboard shortcuts

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