application

package
v0.13.7 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package application provides a runtime model of applications and their versions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NumApplications

func NumApplications(t *testing.T, length int) bool

NumApplications asserts that the number of applications in the application map equals the given length

Types

type Application

type Application struct {
	// Name is of the form namespace/Name where the Name is the value of the label app.kubernetes.io/Name
	Name string `json:"name" yaml:"name"`
	// Tracks is map from application track identifier to version name
	Tracks Tracks `json:"tracks" yaml:"tracks"`
	// Versions maps version name to version data (a set of metrics)
	Versions `json:"versions" yaml:"versions"`
}

Application is an application observed in a kubernetes cluster

func NewApplication

func NewApplication(name string) *Application

NewApplication returns a new Application object with name

func (*Application) ClearTracks

func (a *Application) ClearTracks()

ClearTracks clears the mapping of track identfiers to version names

func (*Application) GetVersion

func (a *Application) GetVersion(version string, allowNew bool) (*Version, bool)

GetVersion returns the Version object corresponding to a given version name If no corresponding version object exists, a new one will be created when allowNew is set to true returns the version object and a boolean indicating whether or not a new version was created or not

func (*Application) MarshalJSON

func (a *Application) MarshalJSON() ([]byte, error)

MarshalJSON creates a JSONified byte array out of application

func (*Application) String

func (a *Application) String() string

String returns a string representation of the Application

func (*Application) UnmarshalJSON

func (a *Application) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals an application from a byte array. This is a custom JSON unmarshaller to ensurer that maps are initialized

type ThreadSafeApplicationMap

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

ThreadSafeApplicationMap is type to control thread safety of operations on an application map

var (
	// Applications is map of app name to Application
	// This is a global variable used to maintain an internal representation of the applications in a cluster
	Applications ThreadSafeApplicationMap
	// BatchWriteInterval is the interval over which changes may batched before being persisted
	BatchWriteInterval time.Duration
)

func (*ThreadSafeApplicationMap) BatchedWrite

func (m *ThreadSafeApplicationMap) BatchedWrite(a *Application) error

BatchedWrite writes the Application to persistent storage only if the previous write was more than BatchWriteInterval ago.

func (*ThreadSafeApplicationMap) Clear

func (m *ThreadSafeApplicationMap) Clear()

Clear the application map

func (*ThreadSafeApplicationMap) Get

func (m *ThreadSafeApplicationMap) Get(application string) (*Application, error)

Get application object from in memory map

func (*ThreadSafeApplicationMap) Lock

func (m *ThreadSafeApplicationMap) Lock(application string)

Lock lock application for writing

func (*ThreadSafeApplicationMap) Put

Put adds an application into the application map if it is not already there Returns the application that is/was there

func (*ThreadSafeApplicationMap) RLock

func (m *ThreadSafeApplicationMap) RLock(application string)

RLock lock application for reading

func (*ThreadSafeApplicationMap) RUnlock

func (m *ThreadSafeApplicationMap) RUnlock(application string)

RUnlock undoes a single RLock call

func (*ThreadSafeApplicationMap) Read

func (m *ThreadSafeApplicationMap) Read(application string) (*Application, error)

Read the application object if necessary from persistent storage (a secret)

func (*ThreadSafeApplicationMap) Unlock

func (m *ThreadSafeApplicationMap) Unlock(application string)

Unlock unlocks application

func (*ThreadSafeApplicationMap) Write

Write writes the Application to persistent storage (a Kubernetes secret)

type Tracks

type Tracks map[string]string

Tracks is map of track identifiers to version names

type Version

type Version struct {
	// List of (summary) metrics for a version
	Metrics map[string]*summarymetrics.SummaryMetric `json:"metrics" yaml:"metrics"`
}

Version is information about versions of an application in a Kubernetes cluster

func (*Version) GetMetric

func (v *Version) GetMetric(metric string, allowNew bool) (*summarymetrics.SummaryMetric, bool)

GetMetric returns a metric from the list of metrics associated with a version If no metric is present for a given name, a new one is created

func (*Version) String

func (v *Version) String() string

type Versions

type Versions map[string]*Version

Versions is a map of the version name to a version object

Jump to

Keyboard shortcuts

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