marathon

package
v0.0.0-...-afc2af5 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ApplicationImmunityLabel = "APP_IMMUNITY"

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Labels      map[string]string `json:"labels"`
	ID          AppID             `json:"id"`
	Tasks       []Task            `json:"tasks"`
	Instances   int               `json:"instances"`
	VersionInfo VersionInfo       `json:"versionInfo"`
}

App represents application returned in marathon json

func ParseApp

func ParseApp(jsonBlob []byte) (*App, error)

ParseApp json

func ParseApps

func ParseApps(jsonBlob []byte) ([]*App, error)

ParseApps json

func (App) HasImmunity

func (app App) HasImmunity() bool

HasImmunity check if application behavior is tolerated without consequence

type AppID

type AppID string

AppID Marathon Application Id (aka PathId) Usually in the form of /rootGroup/subGroup/subSubGroup/name allowed characters: lowercase letters, digits, hyphens, slash

func (AppID) String

func (id AppID) String() string

String stringer for app

type AppWrapper

type AppWrapper struct {
	App App `json:"app"`
}

AppWrapper json returned from marathon with app definition

type AppsResponse

type AppsResponse struct {
	Apps []*App `json:"apps"`
}

AppsResponse json returned from marathon with apps definitions

type Config

type Config struct {
	Location string
	Protocol string
	Username string
	Password string
	// AppIDPrefix is a part of application id preferably present
	// in all applications in marathon, if found it is removed for the sake of
	// making applications paths shorter.
	// By default this string is empty and no prefix is considered.
	AppIDPrefix string
	VerifySsl   bool
	Timeout     time.Duration
}

Config contains marathon module specific configuration

type DeleteResponse

type DeleteResponse struct {
	Version      string `json:"version"`
	DeploymentID string `json:"deploymentId"`
}

DeleteResponse represents marathon response from scaling request

type FailCounter

type FailCounter struct {
	Counter int
}

FailCounter is structure to hold state between failures

type Group

type Group struct {
	Apps    []*App   `json:"apps"`
	Groups  []*Group `json:"groups"`
	ID      GroupID  `json:"id"`
	Version string   `json:"version"`
}

Group represents application returned in Marathon json

func ParseGroups

func ParseGroups(jsonBlob []byte) ([]*Group, error)

ParseGroups json

func (*Group) IsEmpty

func (g *Group) IsEmpty() bool

IsEmpty checks if group is an empty group

type GroupID

type GroupID string

GroupID represents group id from marathon

func (GroupID) String

func (id GroupID) String() string

// String stringer for group

type GroupsResponse

type GroupsResponse struct {
	Groups []*Group `json:"groups"`
}

GroupsResponse json returned from Marathon with apps definitions

type HealthCheckResult

type HealthCheckResult struct {
	Alive bool `json:"alive"`
}

HealthCheckResult returned from marathon api

type LeaderResponse

type LeaderResponse struct {
	Leader string `json:"leader"`
}

LeaderResponse represents marathon response from /v2/leader request

type MStub

type MStub struct {
	Apps   []*App
	Groups []*Group
	// AppGetFail - Set to true and this Stub get method will return errors
	AppsGetFail bool
	// AppDelFail - Set to true and this Stub methods will return error
	AppDelFail bool
	// AppDelHalfFail - Set to true and this Stub methods will return error at each second call
	AppDelHalfFail   bool
	GroupDelFail     bool
	AppScaleDownFail bool
	FailCounter      *FailCounter
	ScaleCounter     *ScaleCounter
}

MStub is a stub for marathon functionality

func (MStub) AppDelete

func (m MStub) AppDelete(appID AppID) error

AppDelete application by provided AppID

func (MStub) AppGet

func (m MStub) AppGet(appID AppID) (*App, error)

AppGet get stubbed app

func (MStub) AppScaleDown

func (m MStub) AppScaleDown(app *App) error

AppScaleDown by one instance

func (MStub) AppsGet

func (m MStub) AppsGet() ([]*App, error)

AppsGet get stubbed apps

func (MStub) AuthGet

func (m MStub) AuthGet() *url.Userinfo

AuthGet get stubbed auth

func (MStub) GetAppIDPrefix

func (m MStub) GetAppIDPrefix() string

func (MStub) GetEmptyLeafGroups

func (m MStub) GetEmptyLeafGroups() ([]*Group, error)

GetEmptyLeafGroups returns groups from marathon which are leafs in group tree

func (MStub) GroupDelete

func (m MStub) GroupDelete(groupID GroupID) error

GroupDelete by provided GroupID

func (MStub) GroupsGet

func (m MStub) GroupsGet() ([]*Group, error)

GroupsGet get stubbed groups

func (MStub) LeaderGet

func (m MStub) LeaderGet() (string, error)

LeaderGet get stubbed leader

func (MStub) LocationGet

func (m MStub) LocationGet() string

LocationGet get stubbed location

func (MStub) TasksGet

func (m MStub) TasksGet(appID AppID) ([]*Task, error)

TasksGet get stubed Tasks

type Marathon

type Marathon struct {
	Location string
	Protocol string

	Auth *url.Userinfo
	// contains filtered or unexported fields
}

Marathon reciever

func New

func New(config Config) (*Marathon, error)

New marathon instance

func (Marathon) AppDelete

func (m Marathon) AppDelete(app AppID) error

AppDelete scales down app by provided AppID

func (Marathon) AppGet

func (m Marathon) AppGet(appID AppID) (*App, error)

AppGet get marathons application from v2/apps/<AppID>

func (Marathon) AppScaleDown

func (m Marathon) AppScaleDown(app *App) error

AppScaleDown scales down app by provided AppID

func (Marathon) AppsGet

func (m Marathon) AppsGet() ([]*App, error)

AppsGet get marathons application from v2/apps/<AppID>

func (Marathon) AuthGet

func (m Marathon) AuthGet() *url.Userinfo

AuthGet string from marathon configured instance

func (Marathon) GetAppIDPrefix

func (m Marathon) GetAppIDPrefix() string

func (Marathon) GetEmptyLeafGroups

func (m Marathon) GetEmptyLeafGroups() ([]*Group, error)

GetEmptyLeafGroups returns groups which are leafs of groups directory and only if they are empty (no apps inside).

func (Marathon) GroupDelete

func (m Marathon) GroupDelete(group GroupID) error

GroupDelete scales down app by provided AppID

func (Marathon) LeaderGet

func (m Marathon) LeaderGet() (string, error)

LeaderGet from marathon cluster

func (Marathon) LocationGet

func (m Marathon) LocationGet() string

LocationGet from marathon configured instance

func (Marathon) TasksGet

func (m Marathon) TasksGet(appID AppID) ([]*Task, error)

TasksGet lists marathon tasks for specified AppID

type Marathoner

type Marathoner interface {
	AppGet(AppID) (*App, error)
	AppsGet() ([]*App, error)
	TasksGet(AppID) ([]*Task, error)
	AuthGet() *url.Userinfo
	LocationGet() string
	LeaderGet() (string, error)
	AppScaleDown(*App) error
	AppDelete(AppID) error
	GroupDelete(GroupID) error
	GetEmptyLeafGroups() ([]*Group, error)
	GetAppIDPrefix() string
}

Marathoner interfacing marathon

type ScaleCounter

type ScaleCounter struct {
	Counter int
}

ScaleCounter is counting scaling operations

type ScaleData

type ScaleData struct {
	Instances int               `json:"instances"`
	Labels    map[string]string `json:"labels"`
}

ScaleData marathon scale json representation

type ScaleResponse

type ScaleResponse struct {
	Version      string `json:"version"`
	DeploymentID string `json:"deploymentId"`
}

ScaleResponse represents marathon response from scaling request

type Task

type Task struct {
	ID                 TaskID
	TaskStatus         string              `json:"taskStatus"`
	AppID              AppID               `json:"appId"`
	Host               string              `json:"host"`
	Ports              []int               `json:"ports"`
	HealthCheckResults []HealthCheckResult `json:"healthCheckResults"`
}

Task definition returned in marathon event

func ParseTask

func ParseTask(event []byte) (*Task, error)

ParseTask try to convert raw Task data to json

func ParseTasks

func ParseTasks(jsonBlob []byte) ([]*Task, error)

ParseTasks try to convert raw Tasks data to json

func (Task) GetMetric

func (t Task) GetMetric(prefix string) string

GetMetric returns a string indicating where this applications metric should be placed in graphite in defined prefix. It is done by triming begining prefix (if defined) from application id and replacing appID separators with metrics separators appropriate for graphite.

type TaskID

type TaskID string

TaskID from marathon Usually in the form of AppID.uuid with '/' replaced with '_'

func (TaskID) AppID

func (id TaskID) AppID() AppID

AppID contains string defining application in marathon

func (TaskID) String

func (id TaskID) String() string

type TasksResponse

type TasksResponse struct {
	Tasks []*Task `json:"tasks"`
}

TasksResponse response to TasksGet call

type VersionInfo

type VersionInfo struct {
	LastScalingAt      string `json:"lastScalingAt"`
	LastConfigChangeAt string `json:"lastConfigChangeAt"`
}

VersionInfo represents json field of this name, inside marathon app definition

Jump to

Keyboard shortcuts

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