Documentation ¶
Overview ¶
Package application provides a runtime model of applications and their versions
Index ¶
- func NumApplications(t *testing.T, length int) bool
- type Application
- type ThreadSafeApplicationMap
- func (m *ThreadSafeApplicationMap) BatchedWrite(a *Application) error
- func (m *ThreadSafeApplicationMap) Clear()
- func (m *ThreadSafeApplicationMap) Get(application string) (*Application, error)
- func (m *ThreadSafeApplicationMap) Lock(application string)
- func (m *ThreadSafeApplicationMap) Put(a *Application) *Application
- func (m *ThreadSafeApplicationMap) RLock(application string)
- func (m *ThreadSafeApplicationMap) RUnlock(application string)
- func (m *ThreadSafeApplicationMap) Read(application string) (*Application, error)
- func (m *ThreadSafeApplicationMap) Unlock(application string)
- func (m *ThreadSafeApplicationMap) Write(a *Application) error
- type Tracks
- type Version
- type Versions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
func (m *ThreadSafeApplicationMap) Put(a *Application) *Application
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 ¶
func (m *ThreadSafeApplicationMap) Write(a *Application) error
Write writes the Application to persistent storage (a Kubernetes secret)
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