models

package
Version: v0.0.0-...-17b3830 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2015 License: Apache-2.0, BSD-3-Clause, MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Guid

func Guid() string

Types

type App

type App struct {
	AppGuid    string
	AppVersion string

	Desired            DesiredAppState
	InstanceHeartbeats []InstanceHeartbeat
	CrashCounts        map[int]CrashCount
	// contains filtered or unexported fields
}

func NewApp

func NewApp(appGuid string, appVersion string, desired DesiredAppState, instanceHeartbeats []InstanceHeartbeat, crashCounts map[int]CrashCount) *App

func (*App) CrashCountAtIndex

func (a *App) CrashCountAtIndex(instanceIndex int, currentTime time.Time) CrashCount

func (*App) EvacuatingInstancesAtIndex

func (a *App) EvacuatingInstancesAtIndex(index int) (instances []InstanceHeartbeat)

func (*App) ExtraStartingOrRunningInstances

func (a *App) ExtraStartingOrRunningInstances() (extras []InstanceHeartbeat)

func (*App) HasCrashedInstanceAtIndex

func (a *App) HasCrashedInstanceAtIndex(index int) bool

func (*App) HasRunningInstanceAtIndex

func (a *App) HasRunningInstanceAtIndex(index int) bool

func (*App) HasStartingInstanceAtIndex

func (a *App) HasStartingInstanceAtIndex(index int) bool

func (*App) HasStartingOrRunningInstanceAtIndex

func (a *App) HasStartingOrRunningInstanceAtIndex(index int) bool

func (*App) HasStartingOrRunningInstances

func (a *App) HasStartingOrRunningInstances() bool

func (*App) HeartbeatsByIndex

func (a *App) HeartbeatsByIndex() (heartbeatsByIndex map[int][]InstanceHeartbeat)

func (*App) InstanceHeartbeatsAtIndex

func (a *App) InstanceHeartbeatsAtIndex(index int) (heartbeats []InstanceHeartbeat)

func (*App) InstanceWithGuid

func (a *App) InstanceWithGuid(instanceGuid string) InstanceHeartbeat

func (*App) IsDesired

func (a *App) IsDesired() bool

func (*App) IsIndexDesired

func (a *App) IsIndexDesired(index int) bool

func (*App) IsStaged

func (a *App) IsStaged() bool

func (*App) LogDescription

func (a *App) LogDescription() map[string]string

func (*App) MarshalJSON

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

func (*App) NumberOfCrashedIndices

func (a *App) NumberOfCrashedIndices() (count int)

func (*App) NumberOfCrashedInstances

func (a *App) NumberOfCrashedInstances() (count int)

func (*App) NumberOfDesiredIndicesReporting

func (a *App) NumberOfDesiredIndicesReporting() (count int)

func (*App) NumberOfDesiredIndicesWithAStartingOrRunningInstance

func (a *App) NumberOfDesiredIndicesWithAStartingOrRunningInstance() (count int)

func (*App) NumberOfDesiredInstances

func (a *App) NumberOfDesiredInstances() int

func (*App) NumberOfStartingOrRunningInstances

func (a *App) NumberOfStartingOrRunningInstances() (count int)

func (*App) StartingOrRunningInstancesAtIndex

func (a *App) StartingOrRunningInstancesAtIndex(index int) (instances []InstanceHeartbeat)

func (*App) ToJSON

func (a *App) ToJSON() []byte

type AppPackageState

type AppPackageState string
const (
	AppPackageStateInvalid AppPackageState = ""
	AppPackageStateFailed  AppPackageState = "FAILED"
	AppPackageStatePending AppPackageState = "PENDING"
	AppPackageStateStaged  AppPackageState = "STAGED"
)

type AppState

type AppState string

Desired app state

const (
	AppStateInvalid AppState = ""
	AppStateStarted AppState = "STARTED"
	AppStateStopped AppState = "STOPPED"
)

type BasicAuthInfo

type BasicAuthInfo struct {
	User     string
	Password string
}

func DecodeBasicAuthInfo

func DecodeBasicAuthInfo(encoded string) (BasicAuthInfo, error)

func (BasicAuthInfo) Encode

func (info BasicAuthInfo) Encode() string

type CrashCount

type CrashCount struct {
	AppGuid       string `json:"droplet"`
	AppVersion    string `json:"version"`
	InstanceIndex int    `json:"instance_index"`
	CrashCount    int    `json:"crash_count"`
	CreatedAt     int64  `json:"created_at"`
}

func NewCrashCountFromJSON

func NewCrashCountFromJSON(encoded []byte) (CrashCount, error)

func (CrashCount) StoreKey

func (crashCount CrashCount) StoreKey() string

func (CrashCount) ToJSON

func (crashCount CrashCount) ToJSON() []byte

type DesiredAppState

type DesiredAppState struct {
	AppGuid           string          `json:"id"`
	AppVersion        string          `json:"version"`
	NumberOfInstances int             `json:"instances"`
	State             AppState        `json:"state"`
	PackageState      AppPackageState `json:"package_state"`
}

func NewDesiredAppStateFromCSV

func NewDesiredAppStateFromCSV(appGuid, appVersion string, encoded []byte) (DesiredAppState, error)

func NewDesiredAppStateFromJSON

func NewDesiredAppStateFromJSON(encoded []byte) (DesiredAppState, error)

func (DesiredAppState) Equal

func (state DesiredAppState) Equal(other DesiredAppState) bool

func (DesiredAppState) LogDescription

func (state DesiredAppState) LogDescription() map[string]string

func (DesiredAppState) StoreKey

func (state DesiredAppState) StoreKey() string

func (DesiredAppState) ToCSV

func (state DesiredAppState) ToCSV() []byte

func (DesiredAppState) ToJSON

func (state DesiredAppState) ToJSON() []byte

type DropletExited

type DropletExited struct {
	CCPartition     string              `json:"cc_partition"`
	AppGuid         string              `json:"droplet"`
	AppVersion      string              `json:"version"`
	InstanceGuid    string              `json:"instance"`
	InstanceIndex   int                 `json:"index"`
	Reason          DropletExitedReason `json:"reason"`
	ExitStatusCode  int                 `json:"exit_status"`
	ExitDescription string              `json:"exit_description"`
	CrashTimestamp  int64               `json:"crash_timestamp,omitempty"`
}

func NewDropletExitedFromJSON

func NewDropletExitedFromJSON(encoded []byte) (DropletExited, error)

func (DropletExited) LogDescription

func (dropletExited DropletExited) LogDescription() map[string]string

func (DropletExited) ToJSON

func (dropletExited DropletExited) ToJSON() []byte

type DropletExitedReason

type DropletExitedReason string
const (
	DropletExitedReasonInvalid       DropletExitedReason = ""
	DropletExitedReasonStopped       DropletExitedReason = "STOPPED"
	DropletExitedReasonCrashed       DropletExitedReason = "CRASHED"
	DropletExitedReasonDEAShutdown   DropletExitedReason = "DEA_SHUTDOWN"
	DropletExitedReasonDEAEvacuation DropletExitedReason = "DEA_EVACUATION"
)

type DropletUpdatedMessage

type DropletUpdatedMessage struct {
	AppGuid string `json:"droplet"`
}

type FreshnessTimestamp

type FreshnessTimestamp struct {
	Timestamp int64 `json:"timestamp"`
}

type Heartbeat

type Heartbeat struct {
	DeaGuid            string              `json:"dea"`
	InstanceHeartbeats []InstanceHeartbeat `json:"droplets"`
}

func NewHeartbeatFromJSON

func NewHeartbeatFromJSON(encoded []byte) (Heartbeat, error)

func (Heartbeat) LogDescription

func (heartbeat Heartbeat) LogDescription() map[string]string

func (Heartbeat) ToJSON

func (heartbeat Heartbeat) ToJSON() []byte

type InstanceHeartbeat

type InstanceHeartbeat struct {
	AppGuid        string        `json:"droplet"`
	AppVersion     string        `json:"version"`
	InstanceGuid   string        `json:"instance"`
	InstanceIndex  int           `json:"index"`
	State          InstanceState `json:"state"`
	StateTimestamp float64       `json:"state_timestamp"`
	DeaGuid        string        `json:"dea_guid"`
}

func NewInstanceHeartbeatFromCSV

func NewInstanceHeartbeatFromCSV(appGuid, appVersion, instanceGuid string, encoded []byte) (InstanceHeartbeat, error)

func NewInstanceHeartbeatFromJSON

func NewInstanceHeartbeatFromJSON(encoded []byte) (InstanceHeartbeat, error)

func (InstanceHeartbeat) IsCrashed

func (instance InstanceHeartbeat) IsCrashed() bool

func (InstanceHeartbeat) IsEvacuating

func (instance InstanceHeartbeat) IsEvacuating() bool

func (InstanceHeartbeat) IsRunning

func (instance InstanceHeartbeat) IsRunning() bool

func (InstanceHeartbeat) IsStarting

func (instance InstanceHeartbeat) IsStarting() bool

func (InstanceHeartbeat) IsStartingOrRunning

func (instance InstanceHeartbeat) IsStartingOrRunning() bool

func (InstanceHeartbeat) LogDescription

func (instance InstanceHeartbeat) LogDescription() map[string]string

func (InstanceHeartbeat) StoreKey

func (instance InstanceHeartbeat) StoreKey() string

func (InstanceHeartbeat) ToCSV

func (instance InstanceHeartbeat) ToCSV() []byte

func (InstanceHeartbeat) ToJSON

func (instance InstanceHeartbeat) ToJSON() []byte

type InstanceState

type InstanceState string
const (
	InstanceStateInvalid    InstanceState = ""
	InstanceStateStarting   InstanceState = "STARTING"
	InstanceStateRunning    InstanceState = "RUNNING"
	InstanceStateCrashed    InstanceState = "CRASHED"
	InstanceStateEvacuating InstanceState = "EVACUATING"
)

type PendingMessage

type PendingMessage struct {
	MessageId  string `json:"message_id"`
	SendOn     int64  `json:"send_on"`
	SentOn     int64  `json:"sent_on"`
	KeepAlive  int    `json:"keep_alive"`
	AppGuid    string `json:"droplet"`
	AppVersion string `json:"version"`
}

func (PendingMessage) HasBeenSent

func (message PendingMessage) HasBeenSent() bool

func (PendingMessage) IsExpired

func (message PendingMessage) IsExpired(currentTime time.Time) bool

func (PendingMessage) IsTimeToSend

func (message PendingMessage) IsTimeToSend(currentTime time.Time) bool

type PendingStartMessage

type PendingStartMessage struct {
	PendingMessage
	IndexToStart     int                       `json:"index"`
	Priority         float64                   `json:"priority"`
	SkipVerification bool                      `json:"skip_verification"` //This only exists to allow the evacuator to specify that a message *must* be sent, regardless of verification status
	StartReason      PendingStartMessageReason `json:"start_reason"`
}

func NewPendingStartMessage

func NewPendingStartMessage(now time.Time, delayInSeconds int, keepAliveInSeconds int, appGuid string, appVersion string, indexToStart int, priority float64, startReason PendingStartMessageReason) PendingStartMessage

func NewPendingStartMessageFromJSON

func NewPendingStartMessageFromJSON(encoded []byte) (PendingStartMessage, error)

func SortStartMessagesByPriority

func SortStartMessagesByPriority(messages map[string]PendingStartMessage) []PendingStartMessage

func (PendingStartMessage) Equal

func (message PendingStartMessage) Equal(another PendingStartMessage) bool

func (PendingStartMessage) LogDescription

func (message PendingStartMessage) LogDescription() map[string]string

func (PendingStartMessage) StoreKey

func (message PendingStartMessage) StoreKey() string

func (PendingStartMessage) ToJSON

func (message PendingStartMessage) ToJSON() []byte

type PendingStartMessageReason

type PendingStartMessageReason string
const (
	PendingStartMessageReasonInvalid    PendingStartMessageReason = ""
	PendingStartMessageReasonCrashed    PendingStartMessageReason = "CRASHED"
	PendingStartMessageReasonMissing    PendingStartMessageReason = "MISSING"
	PendingStartMessageReasonEvacuating PendingStartMessageReason = "EVACUATING"
)

type PendingStopMessage

type PendingStopMessage struct {
	PendingMessage
	InstanceGuid string                   `json:"instance"`
	StopReason   PendingStopMessageReason `json:"stop_reason"`
}

func NewPendingStopMessage

func NewPendingStopMessage(now time.Time, delayInSeconds int, keepAliveInSeconds int, appGuid string, appVersion string, instanceGuid string, stopReason PendingStopMessageReason) PendingStopMessage

func NewPendingStopMessageFromJSON

func NewPendingStopMessageFromJSON(encoded []byte) (PendingStopMessage, error)

func (PendingStopMessage) Equal

func (message PendingStopMessage) Equal(another PendingStopMessage) bool

func (PendingStopMessage) LogDescription

func (message PendingStopMessage) LogDescription() map[string]string

func (PendingStopMessage) StoreKey

func (message PendingStopMessage) StoreKey() string

func (PendingStopMessage) ToJSON

func (message PendingStopMessage) ToJSON() []byte

type PendingStopMessageReason

type PendingStopMessageReason string
const (
	PendingStopMessageReasonInvalid            PendingStopMessageReason = ""
	PendingStopMessageReasonExtra              PendingStopMessageReason = "EXTRA"
	PendingStopMessageReasonDuplicate          PendingStopMessageReason = "DUPLICATE"
	PendingStopMessageReasonEvacuationComplete PendingStopMessageReason = "EVACUATION_COMPLETE"
)

type StartMessage

type StartMessage struct {
	MessageId     string `json:"message_id"`
	AppGuid       string `json:"droplet"`
	AppVersion    string `json:"version"`
	InstanceIndex int    `json:"instance_index"`
}

func NewStartMessageFromJSON

func NewStartMessageFromJSON(encoded []byte) (StartMessage, error)

func (StartMessage) ToJSON

func (message StartMessage) ToJSON() []byte

type StopMessage

type StopMessage struct {
	MessageId     string `json:"message_id"`
	AppGuid       string `json:"droplet"`
	AppVersion    string `json:"version"`
	InstanceGuid  string `json:"instance_guid"`
	InstanceIndex int    `json:"instance_index"`
	IsDuplicate   bool   `json:"is_duplicate"`
}

func NewStopMessageFromJSON

func NewStopMessageFromJSON(encoded []byte) (StopMessage, error)

func (StopMessage) ToJSON

func (message StopMessage) ToJSON() []byte

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL