api

package
v0.0.0-...-33bb219 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package api defines API between Microscaling agent and server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppsFromData

func AppsFromData(b []byte) (tasks []*demand.Task, maxContainers int, err error)

AppsFromData converts apps data from json into tasks.

func GetApps

func GetApps(apiAddress string, userID string) (tasks []*demand.Task, maxContainers int, err error)

GetApps retrives the app definitions from the server for a given userID

func SendMetrics

func SendMetrics(ws *websocket.Conn, userID string, tasks *demand.Tasks) error

SendMetrics sends the current state of tasks to the API

Types

type AppDescription

type AppDescription struct {
	Name              string          `json:"name"`
	Priority          int             `json:"priority"` // 1 is the highest, 0 means it's not scalable
	MinContainers     int             `json:"minContainers"`
	MaxContainers     int             `json:"maxContainers"`
	TargetQueueLength int             `json:"targetValue"`
	RuleType          string          `json:"ruleType"`
	AppType           string          `json:"appType"`
	MetricType        string          `json:"metricType"`
	Config            DockerAppConfig `json:"config"`
}

AppDescription is the json describing an individual app

type AppsMessage

type AppsMessage struct {
	UserID        string           `json:"name"`
	MaxContainers int              `json:"maxContainers"`
	Apps          []AppDescription `json:"apps"`
}

AppsMessage is the json that arrives from /apps/<userID>

type DemandPayload

type DemandPayload struct {
	Demand demandUpdate `json:"demand"`
}

DemandPayload is the JSON sent from the server describing the number of containers needed for each task This is only used if we're generating demand server-sde

type DockerAppConfig

type DockerAppConfig struct {
	Image           string `json:"image"`
	Command         string `json:"command"`
	PublishAllPorts bool   `json:"publishAllPorts"`
	QueueLength     int    `json:"targetQueueLength"`
	QueueName       string `json:"queueName"`
	TopicName       string `json:"topicName"`
	ChannelName     string `json:"channelName"`
	QueueURL        string `json:"queueURL"`
}

DockerAppConfig is the json describing parameters that need to be passed into Docker when starting this app TODO!! This is not really just Docker-specific as we have some target info in here too

Jump to

Keyboard shortcuts

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