worker

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2017 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoWorker = fmt.Errorf("cds: no worker found")

ErrNoWorker means the given worker ID is not found

View Source
var WorkerHeartbeatTimeout = 30.0

WorkerHeartbeatTimeout defines the number of seconds allowed for workers to refresh their beat

Functions

func CreateBuiltinActions

func CreateBuiltinActions(db *sql.DB) error

CreateBuiltinActions add builtin actions in database if needed

func CreateBuiltinEnvironments

func CreateBuiltinEnvironments(db *sql.DB) error

CreateBuiltinEnvironments creates default environment if needed

func DeleteWorker

func DeleteWorker(db *sql.DB, id string) error

DeleteWorker remove worker from database

func DeleteWorkerModel

func DeleteWorkerModel(db gorp.SqlExecutor, ID int64) error

DeleteWorkerModel removes from database worker model informations and all its capabilities

func DeleteWorkerModelCapability

func DeleteWorkerModelCapability(db database.Executer, workerID int64, capaName string) error

DeleteWorkerModelCapability removes a capability from existing worker model

func EstimateWorkerModelNeeds

func EstimateWorkerModelNeeds(db *sql.DB, uid int64, workerModelStatus ModelStatusFunc, actionCount ActionCountFunc) ([]sdk.ModelStatus, error)

EstimateWorkerModelNeeds returns for each worker model the needs of instances

func FindBuildingWorker

func FindBuildingWorker(db database.Querier, actionBuildID string) (string, error)

FindBuildingWorker retrieves in database the worker building given actionBuildID

func GenerateToken

func GenerateToken() (string, error)

GenerateToken generate a random 64bytes hexadecimal string

func GetModelCapabilities

func GetModelCapabilities(db database.Querier, modelID int64) ([]sdk.Requirement, error)

GetModelCapabilities load model capabilities from cache

func Heartbeat

func Heartbeat()

Heartbeat runs in a goroutine and check last beat from all workers on a 10s basis

func InsertToken

func InsertToken(db *sql.DB, groupID int64, token string, e sdk.Expiration) error

InsertToken inserts a new token in database

func InsertWorker

func InsertWorker(db database.Executer, w *sdk.Worker, groupID int64) error

InsertWorker inserts worker representation into database

func InsertWorkerModel

func InsertWorkerModel(db gorp.SqlExecutor, model *sdk.Model) error

InsertWorkerModel insert a new worker model in database

func LoadDeadWorkers

func LoadDeadWorkers(db *sql.DB, timeout float64) ([]sdk.Worker, error)

LoadDeadWorkers load worker with refresh last beat > timeout

func LoadSharedWorkerModels

func LoadSharedWorkerModels(db gorp.SqlExecutor) ([]sdk.Model, error)

LoadSharedWorkerModels returns worker models with group shared.infra

func LoadWorker

func LoadWorker(db database.Querier, id string) (*sdk.Worker, error)

LoadWorker retrieves worker in database

func LoadWorkerModelByID

func LoadWorkerModelByID(db gorp.SqlExecutor, ID int64) (*sdk.Model, error)

LoadWorkerModelByID retrieves a specific worker model in database

func LoadWorkerModelByName

func LoadWorkerModelByName(db gorp.SqlExecutor, name string) (*sdk.Model, error)

LoadWorkerModelByName retrieves a specific worker model in database

func LoadWorkerModelCapabilities

func LoadWorkerModelCapabilities(db database.Querier, workerID int64) ([]sdk.Requirement, error)

LoadWorkerModelCapabilities retrieves capabilities of given worker model

func LoadWorkerModelStatusForAdminUser

func LoadWorkerModelStatusForAdminUser(db *sql.DB, userID int64) ([]sdk.ModelStatus, error)

LoadWorkerModelStatusForAdminUser lods worker model status for group

func LoadWorkerModelStatusForGroup

func LoadWorkerModelStatusForGroup(db *sql.DB, groupID int64) ([]sdk.ModelStatus, error)

LoadWorkerModelStatusForGroup lods worker model status for group

func LoadWorkerModels

func LoadWorkerModels(db gorp.SqlExecutor) ([]sdk.Model, error)

LoadWorkerModels retrieves models from database

func LoadWorkerModelsByGroup

func LoadWorkerModelsByGroup(db gorp.SqlExecutor, groupID int64) ([]sdk.Model, error)

LoadWorkerModelsByGroup returns worker models for a group

func LoadWorkerModelsByUser

func LoadWorkerModelsByUser(db gorp.SqlExecutor, userID int64) ([]sdk.Model, error)

LoadWorkerModelsByUser returns worker models list according to user's groups

func LoadWorkerModelsUsableOnGroup

func LoadWorkerModelsUsableOnGroup(db gorp.SqlExecutor, groupID, sharedinfraGroupID int64) ([]sdk.Model, error)

LoadWorkerModelsUsableOnGroup returns worker models for a group

func LoadWorkers

func LoadWorkers(db *sql.DB) ([]sdk.Worker, error)

LoadWorkers load all workers in db

func LoadWorkersByModel

func LoadWorkersByModel(db database.Querier, modelID int64) ([]sdk.Worker, error)

LoadWorkersByModel load workers by model

func ModelCapabilititiesCacheLoader

func ModelCapabilititiesCacheLoader(delay time.Duration)

ModelCapabilititiesCacheLoader set all model Capabilities in the cache

func RefreshWorker

func RefreshWorker(db *sql.DB, workerID string) error

RefreshWorker Update worker last_beat

func RegisterWorker

func RegisterWorker(db *sql.DB, name string, key string, modelID int64, h *sdk.Hatchery, binaryCapabilities []string) (*sdk.Worker, error)

RegisterWorker Register new worker

func SetStatus

func SetStatus(db database.Executer, workerID string, status sdk.Status) error

SetStatus sets action_build_id and status to building on given worker

func SetToBuilding

func SetToBuilding(db database.Executer, workerID string, actionBuildID int64) error

SetToBuilding sets action_build_id and status to building on given worker

func UpdateWorkerModel

func UpdateWorkerModel(db gorp.SqlExecutor, model sdk.Model) error

UpdateWorkerModel update a worker model

func UpdateWorkerModelCapability

func UpdateWorkerModelCapability(db database.Executer, capa sdk.Requirement, modelID int64) error

UpdateWorkerModelCapability update a worker model capability

func UpdateWorkerStatus

func UpdateWorkerStatus(db database.Executer, workerID string, status sdk.Status) error

UpdateWorkerStatus changes worker status to Disabled

Types

type ActionBuildInfo

type ActionBuildInfo struct {
	ActionBuild sdk.ActionBuild
	Action      sdk.Action
	Secrets     []sdk.Variable
}

ActionBuildInfo is returned to worker in answer to takeActionBuildHandler

type ActionCount

type ActionCount struct {
	Action sdk.Action
	Count  int64
}

ActionCount represents a count of action

func LoadAllActionCount

func LoadAllActionCount(db *sql.DB, userID int64) ([]ActionCount, error)

LoadAllActionCount counts all waiting actions

func LoadGroupActionCount

func LoadGroupActionCount(db *sql.DB, groupID int64) ([]ActionCount, error)

LoadGroupActionCount counts waiting action for group

type ActionCountFunc

type ActionCountFunc func(*sql.DB, int64) ([]ActionCount, error)

ActionCountFunc ...

type ModelStatusFunc

type ModelStatusFunc func(*sql.DB, int64) ([]sdk.ModelStatus, error)

ModelStatusFunc ...

type RegistrationForm

type RegistrationForm struct {
	Name               string
	UserKey            string
	Model              int64
	Hatchery           int64
	BinaryCapabilities []string
}

RegistrationForm represents the arguments needed to register a worker

type Token

type Token struct {
	GroupID    int64          `json:"group_id"`
	Token      string         `json:"token"`
	Expiration sdk.Expiration `json:"expiration"`
	Created    time.Time      `json:"created"`
}

Token describes tokens used by worker to access the API on behalf of a group.

func LoadToken

func LoadToken(db *sql.DB, token string) (Token, error)

LoadToken fetch token infos from database

Jump to

Keyboard shortcuts

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