common

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Busy state defines a resource being used.
	Busy = "busy"
	// Dirty state defines a resource that needs cleaning
	Dirty = "dirty"
	// Free state defines a resource that is usable
	Free = "free"
	// Cleaning state defines a resource being cleaned
	Cleaning = "cleaning"
	// Leased state defines a resource being leased in order to make a new resource
	Leased = "leased"
	// Other is used to agglomerate unspecified states for metrics reporting
	Other = "other"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BoskosConfig

type BoskosConfig struct {
	Resources []ResourceEntry `json:"resources,flow"`
}

BoskosConfig defines config used by boskos server

type CommaSeparatedStrings

type CommaSeparatedStrings []string

CommaSeparatedStrings is used to parse comma separated string flag into a list of strings

func (*CommaSeparatedStrings) Set

func (r *CommaSeparatedStrings) Set(value string) error

Set parses the flag value into a CommaSeparatedStrings

func (*CommaSeparatedStrings) String

func (r *CommaSeparatedStrings) String() string

type ConfigType

type ConfigType struct {
	// Identifier of the struct this maps back to
	Type string `json:"type,omitempty"`
	// Marshaled JSON content
	Content string `json:"content,omitempty"`
}

ConfigType gather the type of config to be applied by Mason in order to construct the resource

type Item

type Item interface {
	GetName() string
}

Item interfaces for resources and configs

type LeasedResources

type LeasedResources []string

LeasedResources is a list of resources name that used in order to create another resource by Mason

type MasonConfig

type MasonConfig struct {
	Configs []ResourcesConfig `json:"configs,flow,omitempty"`
}

MasonConfig holds Mason config information

type Metric

type Metric struct {
	Type    string         `json:"type"`
	Current map[string]int `json:"current"`
	Owners  map[string]int `json:"owner"`
}

Metric contains analytics about a specific resource type

type Resource

type Resource struct {
	Type       string    `json:"type"`
	Name       string    `json:"name"`
	State      string    `json:"state"`
	Owner      string    `json:"owner"`
	LastUpdate time.Time `json:"lastupdate"`
	// Customized UserData
	UserData *UserData `json:"userdata"`
}

Resource abstracts any resource type that can be tracked by boskos

func ItemToResource

func ItemToResource(i Item) (Resource, error)

ItemToResource casts a Item back to a Resource

func NewResource

func NewResource(name, rtype, state, owner string, t time.Time) Resource

NewResource creates a new Boskos Resource.

func NewResourcesFromConfig

func NewResourcesFromConfig(e ResourceEntry) []Resource

NewResourcesFromConfig parse the a ResourceEntry into a list of resources

func (Resource) GetName

func (res Resource) GetName() string

GetName implements the Item interface used for storage

type ResourceByName

type ResourceByName []Resource

ResourceByName helps sorting resources by name

func (ResourceByName) Len

func (ut ResourceByName) Len() int

func (ResourceByName) Less

func (ut ResourceByName) Less(i, j int) bool

func (ResourceByName) Swap

func (ut ResourceByName) Swap(i, j int)

type ResourceByUpdateTime

type ResourceByUpdateTime []Resource

ResourceByUpdateTime helps sorting resources by update time

func (ResourceByUpdateTime) Len

func (ut ResourceByUpdateTime) Len() int

func (ResourceByUpdateTime) Less

func (ut ResourceByUpdateTime) Less(i, j int) bool

func (ResourceByUpdateTime) Swap

func (ut ResourceByUpdateTime) Swap(i, j int)

type ResourceEntry

type ResourceEntry struct {
	Type  string   `json:"type"`
	State string   `json:"state"`
	Names []string `json:"names,flow"`
}

ResourceEntry is resource config format defined from config.yaml

type ResourceNeeds

type ResourceNeeds map[string]int

ResourceNeeds maps the type to count of resources types needed

type ResourcesConfig

type ResourcesConfig struct {
	Name   string        `json:"name"`
	Config ConfigType    `json:"config"`
	Needs  ResourceNeeds `json:"needs"`
}

ResourcesConfig holds information to construct a resource. The ResourcesConfig Name maps to the Resource Type All Resource of a given type will be constructed using the same configuration

func ItemToResourcesConfig

func ItemToResourcesConfig(i Item) (ResourcesConfig, error)

ItemToResourcesConfig casts an Item object to a ResourcesConfig

func (ResourcesConfig) GetName

func (conf ResourcesConfig) GetName() string

GetName implements the item interface for storage

type ResourcesConfigByName

type ResourcesConfigByName []ResourcesConfig

ResourcesConfigByName helps sorting ResourcesConfig by name

func (ResourcesConfigByName) Len

func (ut ResourcesConfigByName) Len() int

func (ResourcesConfigByName) Less

func (ut ResourcesConfigByName) Less(i, j int) bool

func (ResourcesConfigByName) Swap

func (ut ResourcesConfigByName) Swap(i, j int)

type TypeToResources

type TypeToResources map[string][]Resource

TypeToResources stores all the leased resources with the same type f

func (TypeToResources) Copy

Copy returns a copy of the TypeToResources

type UserData

type UserData struct {
	sync.Map
}

UserData is a map of Name to user defined interface, serialized into a string

func UserDataFromMap

func UserDataFromMap(m UserDataMap) *UserData

UserDataFromMap returns a UserData from a map

func (*UserData) Extract

func (ud *UserData) Extract(id string, out interface{}) error

Extract unmarshalls a string a given struct if it exists

func (*UserData) FromMap

func (ud *UserData) FromMap(m UserDataMap)

FromMap feels updates user data from a map

func (*UserData) MarshalJSON

func (ud *UserData) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON Marshaler interface

func (*UserData) Set

func (ud *UserData) Set(id string, in interface{}) error

Set marshalls a struct to a string into the UserData

func (*UserData) ToMap

func (ud *UserData) ToMap() UserDataMap

ToMap converts a UserData to UserDataMap

func (*UserData) UnmarshalJSON

func (ud *UserData) UnmarshalJSON(data []byte) error

UnmarshalJSON implements JSON Unmarshaler interface

func (*UserData) Update

func (ud *UserData) Update(new *UserData)

Update updates existing UserData with new UserData. If a key as an empty string, the key will be deleted

type UserDataMap

type UserDataMap map[string]string

UserDataMap is the standard Map version of UserMap, it is used to ease UserMap creation.

type UserDataNotFound

type UserDataNotFound struct {
	ID string
}

UserDataNotFound will be returned if requested resource does not exist.

func (*UserDataNotFound) Error

func (ud *UserDataNotFound) Error() string

Jump to

Keyboard shortcuts

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