instances

package
v0.0.0-...-03d6fc4 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2019 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

instances provides for running a bunch of skiaserve instances.

Index

Constants

View Source
const (
	// MAX_INSTANCES is the max number of concurrent skiaserve instances we
	// support in the hosted environment.
	MAX_INSTANCES = 200

	// MIN_POOL_SIZE is the number of available spots in the pool that should be
	// maintained at all times. Instances will be culled by oldest lastUsed time
	// until this size is reached.
	MIN_POOL_SIZE = 10

	// START_PORT Is the beginning of the range of ports the skiaserve instances
	// will communicate on.
	START_PORT = 30000

	// START_WAIT_NUM poll the newly started skiaserve this many times before giving up.
	START_WAIT_NUM = 50

	// START_WAIT_PERIOD poll the newly started skiaserve this often.
	START_WAIT_PERIOD = 100 * time.Millisecond

	// EXIT_WAIT_PERIOD is the time to wait for the instance to exit.
	EXIT_WAIT_PERIOD = 2 * time.Second

	// SKIASERVE is the full path to the skiaserve executable.
	SKIASERVE = "/usr/local/bin/skiaserve"
)

Variables

This section is empty.

Functions

func NewInstanceID

func NewInstanceID() string

NewInstanceID creates a new id for an instance of skiaserve.

Types

type InstanceInfo

type InstanceInfo struct {
	ID     string        `json:"id"`
	UUID   string        `json:"uuid"`
	Uptime time.Duration `json:"uptime"`
	Port   int           `json:"port"`
}

type InstanceInfoSlice

type InstanceInfoSlice []*InstanceInfo

func (InstanceInfoSlice) Len

func (p InstanceInfoSlice) Len() int

func (InstanceInfoSlice) Less

func (p InstanceInfoSlice) Less(i, j int) bool

func (InstanceInfoSlice) Swap

func (p InstanceInfoSlice) Swap(i, j int)

type Instances

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

Instances is used to control a number of skiaserve instances all running at the same time.

Instances implements http.handler, which reverse proxies incoming requests to the right backend.

TODO(jcgregorio) Need to add memory limits to instance.

func New

func New(source string) *Instances

func (*Instances) DescribeAll

func (s *Instances) DescribeAll() []*InstanceInfo

func (*Instances) ServeHTTP

func (s *Instances) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface by proxying the requests to the correct instance based on the uuid.

All requests are routed to the instance, with the exception of /instanceStatus and /instanceNew which will be handled by 'co' itself.

func (*Instances) StopAll

func (s *Instances) StopAll()

StopAll stops all running instances.

Jump to

Keyboard shortcuts

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