scheduler

package
v0.0.0-...-7b2e207 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2018 License: AGPL-3.0 Imports: 7 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SupportedCocoonCodeLang = []string{"go"}

SupportedCocoonCodeLang defines the supported chaincode language

Functions

func Getenv

func Getenv(env, defaultVal string) string

Getenv returns an environment variable value based on the schedulers naming convention.

Types

type Artifact

type Artifact struct {
	GetterSource  string
	RelativeDest  string
	GetterOptions map[string]string
}

Artifact defines an artifact to be downloaded

type Check

type Check struct {
	ID       string `json:"Id"`
	Name     string
	Type     string
	Path     string
	Port     string
	Timeout  int64
	Interval int64
	Protocol string
}

Check defines a service check

type Config

type Config struct {
	NetworkMode string    `json:"network_mode"`
	Privileged  bool      `json:"privileged"`
	ForcePull   bool      `json:"force_pull"`
	Volumes     []string  `json:"volumes"`
	Image       string    `json:"image"`
	Command     string    `json:"command"`
	Args        []string  `json:"args"`
	Logging     []Logging `json:"logging"`
}

Config defines a driver/task configuration

type Constraint

type Constraint struct {
	LTarget string
	RTarget string
	Operand string
}

Constraint defines a job/task contraint

type DeploymentInfo

type DeploymentInfo struct {
	ID string
}

DeploymentInfo represents a successful deployment

type DispatchPayload

type DispatchPayload struct {
	File string
}

DispatchPayload configures tast to have access to dispatch payload

type DynamicPort

type DynamicPort struct {
	Label string
}

DynamicPort defines a dynamic port allocation

type EphemeralDisk

type EphemeralDisk struct {
	Sticky  bool
	Migrate bool
	SizeMB  int `mapstructure:"size,omitempty"`
}

EphemeralDisk is an ephemeral disk object

type Job

type Job struct {
	Region      string
	ID          string
	Name        string
	Type        string
	Priority    int
	AllAtOnce   bool
	Datacenters []string
	Constraints []Constraint
	TaskGroups  []TaskGroup
	Update      Update
}

Job defines a nomad job specification

type LogConfig

type LogConfig struct {
	MaxFiles      int
	MaxFileSizeMB int
}

LogConfig defines log configurations

type Logging

type Logging struct {
	Type   string              `json:"type"`
	Config []map[string]string `json:"config"`
}

Logging defines logging configuration

type Network

type Network struct {
	MBits        int
	DynamicPorts []DynamicPort
}

Network defines network allocation

type Nomad

type Nomad struct {
	API string
	// contains filtered or unexported fields
}

Nomad defines a nomad scheduler that implements scheduler.Scheduler interface. Every interaction with the scheduler is handled here.

func NewNomad

func NewNomad() *Nomad

NewNomad creates a nomad scheduler object

func (*Nomad) Deploy

func (sc *Nomad) Deploy(jobID, releaseID string, memory, cpuShare int) (*DeploymentInfo, error)

Deploy a cocoon code to the scheduler

func (*Nomad) GetDeploymentStatus

func (sc *Nomad) GetDeploymentStatus(jobID string) (string, error)

GetDeploymentStatus gets the status of a job

func (*Nomad) GetName

func (sc *Nomad) GetName() string

GetName returns the scheduler name

func (*Nomad) GetServiceDiscoverer

func (sc *Nomad) GetServiceDiscoverer() (ServiceDiscovery, error)

GetServiceDiscoverer returns an instance of the nomad service discovery

func (*Nomad) SetAddr

func (sc *Nomad) SetAddr(addr string, https bool)

SetAddr sets the nomad's API endpoint

func (*Nomad) Stop

func (sc *Nomad) Stop(jobID string) error

Stop stops a running cocoon job

type NomadJob

type NomadJob struct {
	Job *Job
}

NomadJob represents a nomad job

func NewJob

func NewJob(version, id string, count int) *NomadJob

NewJob creates a new job with some default values.

func (*NomadJob) AssignSharedVolume

func (j *NomadJob) AssignSharedVolume() string

AssignSharedVolume adds a shared volume on all tasks. The shared directory is added to the environment of all tasks. Shared volumes will be located in the tmp directory of the host

func (*NomadJob) GetSpec

func (j *NomadJob) GetSpec() *Job

GetSpec returns the job's specification

func (*NomadJob) SetVersion

func (j *NomadJob) SetVersion(v string)

SetVersion set the connectors version

type NomadService

type NomadService struct {
	Name      string
	Tags      []string
	PortLabel string
	Checks    []Check
}

NomadService defines a service

type NomadServiceDiscovery

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

NomadServiceDiscovery provides service discovery to the nomad schedulerAddr by querying a consul server

func NewNomadServiceDiscovery

func NewNomadServiceDiscovery(client *api.Client) *NomadServiceDiscovery

NewNomadServiceDiscovery creates a nomad service discovery instance

func (*NomadServiceDiscovery) GetByID

func (d *NomadServiceDiscovery) GetByID(name string, query map[string]string) ([]*Service, error)

GetByID fetches all the addresses of a service by name.

type Resources

type Resources struct {
	CPU      int
	MemoryMB int
	IOPS     int
	DiskMB   int
	Networks []Network
}

Resources defines the resources to allocate to a task

type RestartPolicy

type RestartPolicy struct {
	Interval int64
	Attempts int
	Delay    int64
	Mode     string
}

RestartPolicy defines restart policy

type Scheduler

type Scheduler interface {
	GetName() string
	Deploy(jobID, releaseID string, memory, cpuShare int) (*DeploymentInfo, error)
	SetAddr(addr string, https bool)
	GetServiceDiscoverer() (ServiceDiscovery, error)
	GetDeploymentStatus(jobID string) (string, error)
	Stop(jobID string) error
}

Scheduler defines an interface for cluster interactions

type Service

type Service struct {
	Name string
	ID   string
	IP   string
	Port int
	Tags []string
}

Service defines a service

type ServiceDiscovery

type ServiceDiscovery interface {
	GetByID(name string, query map[string]string) ([]*Service, error)
}

ServiceDiscovery defines an interface for finding services within a cluster

type Task

type Task struct {
	Name            string
	Driver          string
	Config          Config
	Env             map[string]string
	Services        []NomadService
	Meta            map[string]string
	LogConfig       LogConfig
	KillTimeout     int64
	Templates       []Template
	Artifacts       []Artifact
	Resources       Resources
	DispatchPayload DispatchPayload
}

Task defines a job task

type TaskGroup

type TaskGroup struct {
	Name          string
	Count         int
	Constraints   []string
	Tasks         []*Task
	EphemeralDisk EphemeralDisk
	RestartPolicy RestartPolicy
	Meta          map[string]string
}

TaskGroup defines the task_group stanza

type Template

type Template struct {
	SourcePath   string
	DestPath     string
	EmbeddedTmpl string
	ChangeMode   string
	ChangeSignal string
	Splay        int64
}

Template defines template objects to render for the task

type Update

type Update struct {
	Stagger     int64
	MaxParallel int
}

Update defines the update stanza

Jump to

Keyboard shortcuts

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