cloudburst

package
v0.0.0-...-268cd68 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountActiveInstances

func CountActiveInstances(instances []*Instance, active bool) int

func CountInstancesByStatus

func CountInstancesByStatus(instances []*Instance, status Status) int

Types

type ByResultValues

type ByResultValues func(p1, p2 *ResultValue) bool

func (ByResultValues) Sort

func (by ByResultValues) Sort(vars []*ResultValue)

type Configuration

type Configuration struct {
	PrometheusURL string `json:"prometheus_url"`
	ScrapeTargets []struct {
		Name         string `json:"name"`
		Path         string `json:"path"`
		Description  string `json:"description"`
		Query        string `json:"query"`
		ProviderSpec struct {
			Weights map[string]int `json:"weights"`
		} `json:"provider"`
		InstanceSpec struct {
			ContainerSpec struct {
				Name  string `json:"name"`
				Image string `json:"image"`
			} `json:"container"`
		} `json:"spec"`
		StaticSpec struct {
			Endpoints []string `json:"endpoints"`
		} `json:"static"`
	} `json:"targets"`
}

type ContainerSpec

type ContainerSpec struct {
	Name  string `json:"name"`
	Image string `json:"image"`
}

type EventType

type EventType string
const (
	InstanceSaveEvent   EventType = "save"
	InstanceRemoveEvent EventType = "remove"
)

type Events

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

Events represents an event bus to broadcast instance updates

func NewEvents

func NewEvents() *Events

NewEvents creates a new event bus for instance events

func (*Events) PublishInstanceEvent

func (e *Events) PublishInstanceEvent(event InstanceEvent)

func (*Events) SubscribeToInstanceEvents

func (e *Events) SubscribeToInstanceEvents(channel chan InstanceEvent) Subscription

func (*Events) UnsubscribeFromInstanceEvents

func (e *Events) UnsubscribeFromInstanceEvents(s Subscription)

type Instance

type Instance struct {
	Name      string         `json:"name"`
	Endpoint  string         `json:"endpoint"`
	Provider  string         `json:"provider"`
	Active    bool           `json:"active"`
	Container ContainerSpec  `json:"container"`
	Status    InstanceStatus `json:"status"`
}

func GetActiveInstances

func GetActiveInstances(instances []*Instance, active bool) []*Instance

func GetInstancesByProvider

func GetInstancesByProvider(instances []*Instance, provider string) []*Instance

func GetInstancesByStatus

func GetInstancesByStatus(instances []*Instance, status Status) []*Instance

func GetInstancesWithoutStatus

func GetInstancesWithoutStatus(instances []*Instance, status Status) []*Instance

func NewInstance

func NewInstance(provider string, spec InstanceSpec) *Instance

TODO: add instance spec as attribute to InstanceDemand

type InstanceEvent

type InstanceEvent struct {
	EventType EventType `json:"type"`

	ScrapeTarget string      `json:"target"`
	Instances    []*Instance `json:"data"`
}

InstanceEvent is an event to be pushed to the instance event bus.

func NewInstanceEvent

func NewInstanceEvent(eventType EventType, instance []*Instance) InstanceEvent

NewInstanceEvent creates a new event to be published via instance event bus.

type InstanceSpec

type InstanceSpec struct {
	Container ContainerSpec `json:"container"`
}

type InstanceStatus

type InstanceStatus struct {
	Agent   string    `json:"agent"`
	Status  Status    `json:"status"`
	Started time.Time `json:"started"`
}

type MetricsReceiver

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

func NewMetricsReceiver

func NewMetricsReceiver(prometheusUrl string) (*MetricsReceiver, error)

func (*MetricsReceiver) Poll

func (m *MetricsReceiver) Poll(query string) (float64, error)

func (*MetricsReceiver) PollFrom

func (m *MetricsReceiver) PollFrom(url string, query string) (float64, error)

type ProviderSpec

type ProviderSpec struct {
	Weights map[string]float32 `json:"weights"`
}

type ReactiveThreshold

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

func NewReactiveThreshold

func NewReactiveThreshold() *ReactiveThreshold

func NewReactiveThresholdWithThreshold

func NewReactiveThresholdWithThreshold(threshold Threshold) *ReactiveThreshold

func (*ReactiveThreshold) Calculate

func (c *ReactiveThreshold) Calculate(scrapeTarget *ScrapeTarget, instances []*Instance, metricValue float64) ScalingResult

type ResultValue

type ResultValue struct {
	Provider       string
	Weight         float32
	InstanceDemand int
	Instances      []*Instance
}

type ScalingResult

type ScalingResult struct {
	Result []*ResultValue // the rounded demand for new instances
}

ScalingResult represents the calculated demand for instances

func (*ScalingResult) Sum

func (s *ScalingResult) Sum() int

type ScrapeTarget

type ScrapeTarget struct {
	Name         string       `json:"name"`
	Path         string       `json:"path"`
	Description  string       `json:"description"`
	Query        string       `json:"query"`
	ProviderSpec ProviderSpec `json:"provider"`
	InstanceSpec InstanceSpec `json:"instanceSpec"`
	StaticSpec   StaticSpec   `json:"static"`
}

func ParseConfiguration

func ParseConfiguration(config Configuration) ([]*ScrapeTarget, error)

type StaticSpec

type StaticSpec struct {
	Endpoints []string `json:"endpoints"`
}

type Status

type Status string
const (
	Unknown    Status = "unknown"
	Pending    Status = "pending"
	Running    Status = "running"
	Failure    Status = "failure"
	Progress   Status = "progress"
	Terminated Status = "terminated"
)

type Subscription

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

Subscription represents a subscription to the Events channel. It is used to identify a registered channel

type Threshold

type Threshold struct {
	Upper int
	Lower int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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