models

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2015 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionTypeDownload     ActionType = "download"
	ActionTypeEmitProgress            = "emit_progress"
	ActionTypeRun                     = "run"
	ActionTypeUpload                  = "upload"
	ActionTypeTimeout                 = "timeout"
	ActionTypeTry                     = "try"
	ActionTypeParallel                = "parallel"
	ActionTypeSerial                  = "serial"
)
View Source
const CcBuildArtifactsUploadUriKey = "cc-build-artifacts-upload-uri"
View Source
const CcDropletUploadUriKey = "cc-droplet-upload-uri"
View Source
const CcTimeoutKey = "timeout"
View Source
const (
	CellServiceName = "Cell"
)
View Source
const CrashBackoffMinDuration = 30 * time.Second
View Source
const DefaultImmediateRestarts = 3
View Source
const DefaultMaxBackoffDuration = 16 * time.Minute
View Source
const DefaultMaxRestarts = 200
View Source
const StaleUnclaimedActualLRPDuration = 30 * time.Second

Variables

View Source
var ErrActualLRPGroupInvalid = errors.New("ActualLRPGroup invalid")
View Source
var ErrInvalidActionType = errors.New("invalid action type")

Functions

func FromJSON

func FromJSON(payload []byte, v Validator) error

func MarshalAction

func MarshalAction(a Action) ([]byte, error)

func ToJSON

func ToJSON(v Validator) ([]byte, error)

func ToJSONArray

func ToJSONArray(vs ...Validator) ([]byte, error)

Types

type Action

type Action interface {
	ActionType() ActionType
	Validator
}

func UnmarshalAction

func UnmarshalAction(data []byte) (Action, error)

type ActionType

type ActionType string

type ActualLRP

type ActualLRP struct {
	ActualLRPKey
	ActualLRPInstanceKey
	ActualLRPNetInfo
	CrashCount      int             `json:"crash_count"`
	CrashReason     string          `json:"crash_reason,omitempty"`
	State           ActualLRPState  `json:"state"`
	PlacementError  string          `json:"placement_error,omitempty"`
	Since           int64           `json:"since"`
	ModificationTag ModificationTag `json:"modification_tag"`
}

func (ActualLRP) AllowsTransitionTo

func (before ActualLRP) AllowsTransitionTo(lrpKey ActualLRPKey, instanceKey ActualLRPInstanceKey, newState ActualLRPState) bool

func (ActualLRP) CellIsMissing

func (actual ActualLRP) CellIsMissing(cellSet CellSet) bool

func (ActualLRP) ShouldRestartCrash

func (actual ActualLRP) ShouldRestartCrash(now time.Time, calc RestartCalculator) bool

func (ActualLRP) ShouldRestartImmediately

func (actual ActualLRP) ShouldRestartImmediately(calc RestartCalculator) bool

func (ActualLRP) ShouldStartUnclaimed

func (actual ActualLRP) ShouldStartUnclaimed(now time.Time) bool

func (ActualLRP) Validate

func (actual ActualLRP) Validate() error

type ActualLRPChange

type ActualLRPChange struct {
	Before ActualLRP
	After  ActualLRP
}

type ActualLRPGroup

type ActualLRPGroup struct {
	Instance   *ActualLRP
	Evacuating *ActualLRP
}

func (ActualLRPGroup) Resolve

func (group ActualLRPGroup) Resolve() (*ActualLRP, bool, error)

type ActualLRPGroupsByIndex

type ActualLRPGroupsByIndex map[int]ActualLRPGroup

func (ActualLRPGroupsByIndex) Slice

func (actuals ActualLRPGroupsByIndex) Slice() []ActualLRPGroup

type ActualLRPInstanceKey

type ActualLRPInstanceKey struct {
	InstanceGuid string `json:"instance_guid"`
	CellID       string `json:"cell_id"`
}

func NewActualLRPInstanceKey

func NewActualLRPInstanceKey(instanceGuid string, cellID string) ActualLRPInstanceKey

func (*ActualLRPInstanceKey) Empty

func (key *ActualLRPInstanceKey) Empty() bool

func (ActualLRPInstanceKey) Validate

func (key ActualLRPInstanceKey) Validate() error

type ActualLRPKey

type ActualLRPKey struct {
	ProcessGuid string `json:"process_guid"`
	Index       int    `json:"index"`
	Domain      string `json:"domain"`
}

func NewActualLRPKey

func NewActualLRPKey(processGuid string, index int, domain string) ActualLRPKey

func (ActualLRPKey) Validate

func (key ActualLRPKey) Validate() error

type ActualLRPNetInfo

type ActualLRPNetInfo struct {
	Address string        `json:"address"`
	Ports   []PortMapping `json:"ports"`
}

func EmptyActualLRPNetInfo

func EmptyActualLRPNetInfo() ActualLRPNetInfo

func NewActualLRPNetInfo

func NewActualLRPNetInfo(address string, ports []PortMapping) ActualLRPNetInfo

func (*ActualLRPNetInfo) Empty

func (info *ActualLRPNetInfo) Empty() bool

func (ActualLRPNetInfo) Validate

func (key ActualLRPNetInfo) Validate() error

type ActualLRPState

type ActualLRPState string
const (
	ActualLRPStateUnclaimed ActualLRPState = "UNCLAIMED"
	ActualLRPStateClaimed   ActualLRPState = "CLAIMED"
	ActualLRPStateRunning   ActualLRPState = "RUNNING"
	ActualLRPStateCrashed   ActualLRPState = "CRASHED"
)

type ActualLRPsByIndex

type ActualLRPsByIndex map[int]ActualLRP

func (ActualLRPsByIndex) Slice

func (actuals ActualLRPsByIndex) Slice() []ActualLRP

type ActualLRPsByProcessGuidAndIndex

type ActualLRPsByProcessGuidAndIndex map[string]ActualLRPsByIndex

func (ActualLRPsByProcessGuidAndIndex) Add

func (ActualLRPsByProcessGuidAndIndex) Each

func (set ActualLRPsByProcessGuidAndIndex) Each(predicate func(actual ActualLRP))

type AuctioneerPresence

type AuctioneerPresence struct {
	AuctioneerID      string `json:"auctioneer_id"`
	AuctioneerAddress string `json:"auctioneer_address"`
}

func NewAuctioneerPresence

func NewAuctioneerPresence(id, address string) AuctioneerPresence

func (AuctioneerPresence) Validate

func (a AuctioneerPresence) Validate() error

type CellCapacity

type CellCapacity struct {
	MemoryMB   int `json:"memory_mb"`
	DiskMB     int `json:"disk_mb"`
	Containers int `json:"containers"`
}

func NewCellCapacity

func NewCellCapacity(memoryMB, diskMB, containers int) CellCapacity

func (CellCapacity) Validate

func (cap CellCapacity) Validate() error

type CellPresence

type CellPresence struct {
	CellID     string       `json:"cell_id"`
	Stack      string       `json:"stack"`
	RepAddress string       `json:"rep_address"`
	Zone       string       `json:"zone"`
	Capacity   CellCapacity `json:"capacity"`
}

func NewCellPresence

func NewCellPresence(cellID, stack, repAddress, zone string, capacity CellCapacity) CellPresence

func (CellPresence) Validate

func (c CellPresence) Validate() error

type CellSet

type CellSet map[string]CellPresence

func (CellSet) Add

func (set CellSet) Add(cell CellPresence)

func (CellSet) Each

func (set CellSet) Each(predicate func(cell CellPresence))

func (CellSet) HasCellID

func (set CellSet) HasCellID(cellID string) bool

type DesiredLRP

type DesiredLRP struct {
	ProcessGuid          string                      `json:"process_guid"`
	Domain               string                      `json:"domain"`
	RootFSPath           string                      `json:"rootfs"`
	Instances            int                         `json:"instances"`
	Stack                string                      `json:"stack"`
	EnvironmentVariables []EnvironmentVariable       `json:"env,omitempty"`
	Setup                Action                      `json:"-"`
	Action               Action                      `json:"-"`
	StartTimeout         uint                        `json:"start_timeout"`
	Monitor              Action                      `json:"-"`
	DiskMB               int                         `json:"disk_mb"`
	MemoryMB             int                         `json:"memory_mb"`
	CPUWeight            uint                        `json:"cpu_weight"`
	Privileged           bool                        `json:"privileged"`
	Ports                []uint16                    `json:"ports"`
	Routes               map[string]*json.RawMessage `json:"routes,omitempty"`
	LogSource            string                      `json:"log_source"`
	LogGuid              string                      `json:"log_guid"`
	MetricsGuid          string                      `json:"metrics_guid"`
	Annotation           string                      `json:"annotation,omitempty"`
	EgressRules          []SecurityGroupRule         `json:"egress_rules,omitempty"`
	ModificationTag      ModificationTag             `json:"modification_tag"`
}

func (DesiredLRP) ApplyUpdate

func (desired DesiredLRP) ApplyUpdate(update DesiredLRPUpdate) DesiredLRP

func (DesiredLRP) MarshalJSON

func (desired DesiredLRP) MarshalJSON() ([]byte, error)

func (*DesiredLRP) UnmarshalJSON

func (desired *DesiredLRP) UnmarshalJSON(payload []byte) error

func (DesiredLRP) Validate

func (desired DesiredLRP) Validate() error

type DesiredLRPChange

type DesiredLRPChange struct {
	Before DesiredLRP
	After  DesiredLRP
}

type DesiredLRPUpdate

type DesiredLRPUpdate struct {
	Instances  *int                        `json:"instances,omitempty"`
	Routes     map[string]*json.RawMessage `json:"routes,omitempty"`
	Annotation *string                     `json:"annotation,omitempty"`
}

type DesiredLRPsByProcessGuid

type DesiredLRPsByProcessGuid map[string]DesiredLRP

func (DesiredLRPsByProcessGuid) Add

func (set DesiredLRPsByProcessGuid) Add(desired DesiredLRP)

func (DesiredLRPsByProcessGuid) Each

func (set DesiredLRPsByProcessGuid) Each(predicate func(desired DesiredLRP))

type DomainSet

type DomainSet map[string]struct{}

func (DomainSet) Add

func (set DomainSet) Add(domain string)

func (DomainSet) Contains

func (set DomainSet) Contains(domain string) bool

func (DomainSet) Each

func (set DomainSet) Each(predicate func(domain string))

type DownloadAction

type DownloadAction struct {
	Artifact string `json:"artifact,omitempty"`
	From     string `json:"from"`
	To       string `json:"to"`
	CacheKey string `json:"cache_key"`

	LogSource string `json:"log_source,omitempty"`
}

func (*DownloadAction) ActionType

func (a *DownloadAction) ActionType() ActionType

func (DownloadAction) Validate

func (a DownloadAction) Validate() error

type EmitProgressAction

type EmitProgressAction struct {
	Action               Action `json:"-"`
	StartMessage         string `json:"start_message"`
	SuccessMessage       string `json:"success_message"`
	FailureMessagePrefix string `json:"failure_message_prefix"`

	LogSource string `json:"log_source,omitempty"`
}

func EmitProgressFor

func EmitProgressFor(action Action, startMessage string, successMessage string, failureMessagePrefix string) *EmitProgressAction

func (*EmitProgressAction) ActionType

func (a *EmitProgressAction) ActionType() ActionType

func (*EmitProgressAction) MarshalJSON

func (a *EmitProgressAction) MarshalJSON() ([]byte, error)

func (*EmitProgressAction) UnmarshalJSON

func (a *EmitProgressAction) UnmarshalJSON(data []byte) error

func (EmitProgressAction) Validate

func (a EmitProgressAction) Validate() error

type EnvironmentVariable

type EnvironmentVariable struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type ErrInvalidField

type ErrInvalidField struct {
	Field string
}

func (ErrInvalidField) Error

func (err ErrInvalidField) Error() string

type ErrInvalidModification

type ErrInvalidModification struct {
	InvalidField string
}

func (ErrInvalidModification) Error

func (err ErrInvalidModification) Error() string

type ErrInvalidParameter

type ErrInvalidParameter struct {
	Parameter string
}

func (ErrInvalidParameter) Error

func (err ErrInvalidParameter) Error() string

type ICMPInfo

type ICMPInfo struct {
	Type int32 `json:"type"`
	Code int32 `json:"code"`
}

type InnerDesiredLRP

type InnerDesiredLRP DesiredLRP

type InnerEmitProgressAction

type InnerEmitProgressAction EmitProgressAction

type InnerTask

type InnerTask Task

type LRPStartRequest

type LRPStartRequest struct {
	DesiredLRP DesiredLRP `json:"desired_lrp"`
	Indices    []uint     `json:"indices"`
}

func NewLRPStartRequest

func NewLRPStartRequest(d DesiredLRP, indices ...uint) LRPStartRequest

func (LRPStartRequest) Validate

func (lrpstart LRPStartRequest) Validate() error

type ModificationTag

type ModificationTag struct {
	Epoch string `json:"epoch"`
	Index uint   `json:"index"`
}

func (*ModificationTag) Increment

func (t *ModificationTag) Increment()

type ParallelAction

type ParallelAction struct {
	Actions []Action

	LogSource string
}

func Parallel

func Parallel(actions ...Action) *ParallelAction

func (*ParallelAction) ActionType

func (a *ParallelAction) ActionType() ActionType

func (*ParallelAction) MarshalJSON

func (a *ParallelAction) MarshalJSON() ([]byte, error)

func (*ParallelAction) UnmarshalJSON

func (a *ParallelAction) UnmarshalJSON(data []byte) error

func (ParallelAction) Validate

func (a ParallelAction) Validate() error

type PortMapping

type PortMapping struct {
	ContainerPort uint16 `json:"container_port"`
	HostPort      uint16 `json:"host_port,omitempty"`
}

type PortRange

type PortRange struct {
	Start uint16 `json:"start"`
	End   uint16 `json:"end"`
}

type ProtocolName

type ProtocolName string
const (
	TCPProtocol  ProtocolName = "tcp"
	UDPProtocol  ProtocolName = "udp"
	ICMPProtocol ProtocolName = "icmp"
	AllProtocol  ProtocolName = "all"
)

type ReceptorPresence

type ReceptorPresence struct {
	ReceptorID  string `json:"id"`
	ReceptorURL string `json:"address"`
}

func NewReceptorPresence

func NewReceptorPresence(id, url string) ReceptorPresence

func (ReceptorPresence) Validate

func (r ReceptorPresence) Validate() error

type ResourceLimits

type ResourceLimits struct {
	Nofile *uint64 `json:"nofile,omitempty"`
}

type RestartCalculator

type RestartCalculator struct {
	ImmediateRestarts  int           `json:"immediate_restarts"`
	MaxBackoffCount    int           `json:"max_backoff_count"`
	MaxBackoffDuration time.Duration `json:"max_backoff_duration"`
	MaxRestartAttempts int           `json:"max_restart_attempts"`
}

func NewDefaultRestartCalculator

func NewDefaultRestartCalculator() RestartCalculator

func NewRestartCalculator

func NewRestartCalculator(immediateRestarts int, maxBackoffDuration time.Duration, maxRestarts int) RestartCalculator

func (RestartCalculator) ShouldRestart

func (r RestartCalculator) ShouldRestart(now, crashedAt int64, crashCount int) bool

func (RestartCalculator) Validate

func (r RestartCalculator) Validate() error

type RunAction

type RunAction struct {
	Path           string                `json:"path"`
	Args           []string              `json:"args"`
	Dir            string                `json:"dir,omitempty"`
	Env            []EnvironmentVariable `json:"env"`
	ResourceLimits ResourceLimits        `json:"resource_limits"`
	Privileged     bool                  `json:"privileged,omitempty"`

	LogSource string `json:"log_source,omitempty"`
}

func (*RunAction) ActionType

func (a *RunAction) ActionType() ActionType

func (RunAction) Validate

func (a RunAction) Validate() error

type SecurityGroupRule

type SecurityGroupRule struct {
	Protocol     ProtocolName `json:"protocol"`
	Destinations []string     `json:"destinations"`
	Ports        []uint16     `json:"ports,omitempty"`
	PortRange    *PortRange   `json:"port_range,omitempty"`
	IcmpInfo     *ICMPInfo    `json:"icmp_info,omitempty"`
	Log          bool         `json:"log"`
}

func (SecurityGroupRule) Validate

func (rule SecurityGroupRule) Validate() error

type SerialAction

type SerialAction struct {
	Actions []Action

	LogSource string
}

func Serial

func Serial(actions ...Action) *SerialAction

func (*SerialAction) ActionType

func (a *SerialAction) ActionType() ActionType

func (*SerialAction) MarshalJSON

func (a *SerialAction) MarshalJSON() ([]byte, error)

func (*SerialAction) UnmarshalJSON

func (a *SerialAction) UnmarshalJSON(data []byte) error

func (SerialAction) Validate

func (a SerialAction) Validate() error

type ServiceRegistration

type ServiceRegistration struct {
	Name string `json:"name"`
	Id   string `json:"id"`
}

type ServiceRegistrations

type ServiceRegistrations []ServiceRegistration

func (ServiceRegistrations) FilterByName

func (s ServiceRegistrations) FilterByName(serviceName string) ServiceRegistrations

type Task

type Task struct {
	TaskGuid             string                `json:"task_guid"`
	Domain               string                `json:"domain"`
	RootFSPath           string                `json:"rootfs"`
	Stack                string                `json:"stack"`
	EnvironmentVariables []EnvironmentVariable `json:"env,omitempty"`
	Action               Action                `json:"-"`
	MemoryMB             int                   `json:"memory_mb"`
	Privileged           bool                  `json:"privileged"`
	DiskMB               int                   `json:"disk_mb"`
	CPUWeight            uint                  `json:"cpu_weight"`
	LogGuid              string                `json:"log_guid"`
	LogSource            string                `json:"log_source"`
	MetricsGuid          string                `json:"metrics_guid"`
	CreatedAt            int64                 `json:"created_at"` //  the number of nanoseconds elapsed since January 1, 1970 UTC
	UpdatedAt            int64                 `json:"updated_at"`
	FirstCompletedAt     int64                 `json:"first_completed_at"`
	ResultFile           string                `json:"result_file"`

	State TaskState `json:"state"`

	CellID string `json:"cell_id"`

	Result        string `json:"result"`
	Failed        bool   `json:"failed"`
	FailureReason string `json:"failure_reason"`

	CompletionCallbackURL *url.URL `json:"completion_callback_url,omitempty"`
	Annotation            string   `json:"annotation,omitempty"`

	EgressRules []SecurityGroupRule `json:"egress_rules,omitempty"`
}

func (Task) MarshalJSON

func (task Task) MarshalJSON() ([]byte, error)

func (*Task) UnmarshalJSON

func (t *Task) UnmarshalJSON(payload []byte) error

func (Task) Validate

func (task Task) Validate() error

type TaskState

type TaskState int
const (
	TaskStateInvalid TaskState = iota
	TaskStatePending
	TaskStateRunning
	TaskStateCompleted
	TaskStateResolving
)

func (TaskState) String

func (i TaskState) String() string

type TimeoutAction

type TimeoutAction struct {
	Action  Action
	Timeout time.Duration

	LogSource string
}

func Timeout

func Timeout(action Action, timeout time.Duration) *TimeoutAction

func (*TimeoutAction) ActionType

func (a *TimeoutAction) ActionType() ActionType

func (*TimeoutAction) MarshalJSON

func (a *TimeoutAction) MarshalJSON() ([]byte, error)

func (*TimeoutAction) UnmarshalJSON

func (a *TimeoutAction) UnmarshalJSON(data []byte) error

func (TimeoutAction) Validate

func (a TimeoutAction) Validate() error

type TryAction

type TryAction struct {
	Action

	LogSource string
}

func Try

func Try(action Action) *TryAction

func (*TryAction) ActionType

func (a *TryAction) ActionType() ActionType

func (*TryAction) MarshalJSON

func (a *TryAction) MarshalJSON() ([]byte, error)

func (*TryAction) UnmarshalJSON

func (a *TryAction) UnmarshalJSON(data []byte) error

func (TryAction) Validate

func (a TryAction) Validate() error

type UploadAction

type UploadAction struct {
	Artifact string `json:"artifact,omitempty"`
	To       string `json:"to"`
	From     string `json:"from"`

	LogSource string `json:"log_source,omitempty"`
}

func (*UploadAction) ActionType

func (a *UploadAction) ActionType() ActionType

func (UploadAction) Validate

func (a UploadAction) Validate() error

type ValidationError

type ValidationError []error

func (ValidationError) Append

func (ve ValidationError) Append(err error) ValidationError

func (ValidationError) Empty

func (ve ValidationError) Empty() bool

func (ValidationError) Error

func (ve ValidationError) Error() string

type Validator

type Validator interface {
	Validate() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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