bbs

package module
v0.0.0-...-8fcca98 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2016 License: Apache-2.0 Imports: 21 Imported by: 0

README

BBS Server

API to access the database for Diego.

API

To interact with the BBS from outside of Diego, use the methods provided on the ExternalClient interface, documented here.

Components within Diego may use the full Client interface to modify internal state.

Code Generation

You need the 3.0 version of the protoc compiler. If you're a Homebrew user on Mac OS X, you get that by running:

brew install protobuf --devel

If you already have an older version of protobuf installed, you will have to uninstall it first: brew uninstall protobuf

You also need the gogoproto compiler in you path:

go install github.com/gogo/protobuf/protoc-gen-gogoslick

We generate code from the .proto (protobuf) files. We also generate a set of fakes from the interfaces we have. To do so, just use go generate.

go generate ./...

Documentation

Index

Constants

View Source
const (
	ContentTypeHeader    = "Content-Type"
	XCfRouterErrorHeader = "X-Cf-Routererror"
	ProtoContentType     = "application/x-protobuf"
	KeepContainer        = true
	DeleteContainer      = false
)
View Source
const (
	// Ping
	PingRoute = "Ping"

	// Domains
	DomainsRoute      = "Domains"
	UpsertDomainRoute = "UpsertDomain"

	// Actual LRPs
	ActualLRPGroupsRoute                     = "ActualLRPGroups"
	ActualLRPGroupsByProcessGuidRoute        = "ActualLRPGroupsByProcessGuid"
	ActualLRPGroupByProcessGuidAndIndexRoute = "ActualLRPGroupsByProcessGuidAndIndex"

	// Actual LRP Lifecycle
	ClaimActualLRPRoute  = "ClaimActualLRP"
	StartActualLRPRoute  = "StartActualLRP"
	CrashActualLRPRoute  = "CrashActualLRP"
	FailActualLRPRoute   = "FailActualLRP"
	RemoveActualLRPRoute = "RemoveActualLRP"
	RetireActualLRPRoute = "RetireActualLRP"

	// Evacuation
	RemoveEvacuatingActualLRPRoute = "RemoveEvacuatingActualLRP"
	EvacuateClaimedActualLRPRoute  = "EvacuateClaimedActualLRP"
	EvacuateCrashedActualLRPRoute  = "EvacuateCrashedActualLRP"
	EvacuateStoppedActualLRPRoute  = "EvacuateStoppedActualLRP"
	EvacuateRunningActualLRPRoute  = "EvacuateRunningActualLRP"

	// Desired LRPs
	DesiredLRPsRoute               = "DesiredLRPs"
	DesiredLRPSchedulingInfosRoute = "DesiredLRPSchedulingInfos"
	DesiredLRPByProcessGuidRoute   = "DesiredLRPByProcessGuid"

	// Desire LRP Lifecycle
	DesireDesiredLRPRoute = "DesireDesiredLRP"
	UpdateDesiredLRPRoute = "UpdateDesireLRP"
	RemoveDesiredLRPRoute = "RemoveDesiredLRP"

	// LRP Convergence
	ConvergeLRPsRoute = "ConvergeLRPs"

	// Tasks
	TasksRoute         = "Tasks"
	TaskByGuidRoute    = "TaskByGuid"
	DesireTaskRoute    = "DesireTask"
	StartTaskRoute     = "StartTask"
	CancelTaskRoute    = "CancelTask"
	FailTaskRoute      = "FailTask"
	CompleteTaskRoute  = "CompleteTask"
	ResolvingTaskRoute = "ResolvingTask"
	DeleteTaskRoute    = "DeleteTask"
	ConvergeTasksRoute = "ConvergeTasks"

	// Event Streaming
	EventStreamRoute = "EventStream"
)
View Source
const (
	CellSchemaKey    = "cell"
	BBSLockSchemaKey = "bbs_lock"
)

Variables

View Source
var Routes = rata.Routes{

	{Path: "/v1/ping", Method: "POST", Name: PingRoute},

	{Path: "/v1/domains/list", Method: "POST", Name: DomainsRoute},
	{Path: "/v1/domains/upsert", Method: "POST", Name: UpsertDomainRoute},

	{Path: "/v1/actual_lrp_groups/list", Method: "POST", Name: ActualLRPGroupsRoute},
	{Path: "/v1/actual_lrp_groups/list_by_process_guid", Method: "POST", Name: ActualLRPGroupsByProcessGuidRoute},
	{Path: "/v1/actual_lrp_groups/get_by_process_guid_and_index", Method: "POST", Name: ActualLRPGroupByProcessGuidAndIndexRoute},

	{Path: "/v1/actual_lrps/claim", Method: "POST", Name: ClaimActualLRPRoute},
	{Path: "/v1/actual_lrps/start", Method: "POST", Name: StartActualLRPRoute},
	{Path: "/v1/actual_lrps/crash", Method: "POST", Name: CrashActualLRPRoute},
	{Path: "/v1/actual_lrps/fail", Method: "POST", Name: FailActualLRPRoute},
	{Path: "/v1/actual_lrps/remove", Method: "POST", Name: RemoveActualLRPRoute},
	{Path: "/v1/actual_lrps/retire", Method: "POST", Name: RetireActualLRPRoute},

	{Path: "/v1/actual_lrps/remove_evacuating", Method: "POST", Name: RemoveEvacuatingActualLRPRoute},
	{Path: "/v1/actual_lrps/evacuate_claimed", Method: "POST", Name: EvacuateClaimedActualLRPRoute},
	{Path: "/v1/actual_lrps/evacuate_crashed", Method: "POST", Name: EvacuateCrashedActualLRPRoute},
	{Path: "/v1/actual_lrps/evacuate_stopped", Method: "POST", Name: EvacuateStoppedActualLRPRoute},
	{Path: "/v1/actual_lrps/evacuate_running", Method: "POST", Name: EvacuateRunningActualLRPRoute},

	{Path: "/v1/desired_lrps/list", Method: "POST", Name: DesiredLRPsRoute},
	{Path: "/v1/desired_lrps/get_by_process_guid", Method: "POST", Name: DesiredLRPByProcessGuidRoute},

	{Path: "/v1/desired_lrp_scheduling_infos/list", Method: "POST", Name: DesiredLRPSchedulingInfosRoute},

	{Path: "/v1/desired_lrp/desire", Method: "POST", Name: DesireDesiredLRPRoute},
	{Path: "/v1/desired_lrp/update", Method: "POST", Name: UpdateDesiredLRPRoute},
	{Path: "/v1/desired_lrp/remove", Method: "POST", Name: RemoveDesiredLRPRoute},

	{Path: "/v1/lrps/converge", Method: "POST", Name: ConvergeLRPsRoute},

	{Path: "/v1/tasks/list", Method: "POST", Name: TasksRoute},
	{Path: "/v1/tasks/get_by_task_guid", Method: "GET", Name: TaskByGuidRoute},

	{Path: "/v1/tasks/desire", Method: "POST", Name: DesireTaskRoute},
	{Path: "/v1/tasks/start", Method: "POST", Name: StartTaskRoute},
	{Path: "/v1/tasks/cancel", Method: "POST", Name: CancelTaskRoute},
	{Path: "/v1/tasks/fail", Method: "POST", Name: FailTaskRoute},
	{Path: "/v1/tasks/complete", Method: "POST", Name: CompleteTaskRoute},
	{Path: "/v1/tasks/resolving", Method: "POST", Name: ResolvingTaskRoute},
	{Path: "/v1/tasks/delete", Method: "POST", Name: DeleteTaskRoute},

	{Path: "/v1/tasks/converge", Method: "POST", Name: ConvergeTasksRoute},

	{Path: "/v1/events", Method: "GET", Name: EventStreamRoute},
}

Functions

func BBSLockSchemaPath

func BBSLockSchemaPath() string

func CellSchemaPath

func CellSchemaPath(cellID string) string

func CellSchemaRoot

func CellSchemaRoot() string

Types

type Client

type Client interface {
	ExternalClient

	ClaimActualLRP(processGuid string, index int, instanceKey *models.ActualLRPInstanceKey) error
	StartActualLRP(key *models.ActualLRPKey, instanceKey *models.ActualLRPInstanceKey, netInfo *models.ActualLRPNetInfo) error
	CrashActualLRP(key *models.ActualLRPKey, instanceKey *models.ActualLRPInstanceKey, errorMessage string) error
	FailActualLRP(key *models.ActualLRPKey, errorMessage string) error
	RemoveActualLRP(processGuid string, index int) error

	EvacuateClaimedActualLRP(*models.ActualLRPKey, *models.ActualLRPInstanceKey) (bool, error)
	EvacuateRunningActualLRP(*models.ActualLRPKey, *models.ActualLRPInstanceKey, *models.ActualLRPNetInfo, uint64) (bool, error)
	EvacuateStoppedActualLRP(*models.ActualLRPKey, *models.ActualLRPInstanceKey) (bool, error)
	EvacuateCrashedActualLRP(*models.ActualLRPKey, *models.ActualLRPInstanceKey, string) (bool, error)
	RemoveEvacuatingActualLRP(*models.ActualLRPKey, *models.ActualLRPInstanceKey) error

	ConvergeLRPs() error

	ConvergeTasks(kickTaskDuration, expirePendingTaskDuration, expireCompletedTaskDuration time.Duration) error
	StartTask(taskGuid string, cellID string) (bool, error)
	FailTask(taskGuid, failureReason string) error
	CompleteTask(taskGuid, cellId string, failed bool, failureReason, result string) error
	ResolvingTask(taskGuid string) error
	DeleteTask(taskGuid string) error
}

The Client interface exposes all available endpoints of the BBS server, including private endpoints which should be used exclusively by internal Diego components. To interact with the BBS from outside of Diego, the ExternalClient should be used instead.

func NewClient

func NewClient(url string) Client

func NewSecureClient

func NewSecureClient(url, caFile, certFile, keyFile string, clientSessionCacheSize, maxIdleConnsPerHost int) (Client, error)

func NewSecureSkipVerifyClient

func NewSecureSkipVerifyClient(url, certFile, keyFile string, clientSessionCacheSize, maxIdleConnsPerHost int) (Client, error)

type ExternalClient

type ExternalClient interface {
	// Returns true if the BBS server is reachable
	Ping() bool

	// Lists the active domains
	Domains() ([]string, error)

	// Creates a domain or bumps the ttl on an existing domain
	UpsertDomain(domain string, ttl time.Duration) error

	// Returns all ActualLRPGroups matching the given ActualLRPFilter
	ActualLRPGroups(models.ActualLRPFilter) ([]*models.ActualLRPGroup, error)

	// Returns all ActualLRPGroups that have the given process guid
	ActualLRPGroupsByProcessGuid(processGuid string) ([]*models.ActualLRPGroup, error)

	// Returns the ActualLRPGroup with the given process guid and instance index
	ActualLRPGroupByProcessGuidAndIndex(processGuid string, index int) (*models.ActualLRPGroup, error)

	// Shuts down the ActualLRP matching the given ActualLRPKey, but does not modify the desired state
	RetireActualLRP(key *models.ActualLRPKey) error

	// Lists all DesiredLRPs that match the given DesiredLRPFilter
	DesiredLRPs(models.DesiredLRPFilter) ([]*models.DesiredLRP, error)

	// Returns the DesiredLRP with the given process guid
	DesiredLRPByProcessGuid(processGuid string) (*models.DesiredLRP, error)

	// Returns all DesiredLRPSchedulingInfos that match the given DesiredLRPFilter
	DesiredLRPSchedulingInfos(models.DesiredLRPFilter) ([]*models.DesiredLRPSchedulingInfo, error)

	// Creates the given DesiredLRP and its corresponding ActualLRPs
	DesireLRP(*models.DesiredLRP) error

	// Updates the DesiredLRP matching the given process guid
	UpdateDesiredLRP(processGuid string, update *models.DesiredLRPUpdate) error

	// Removes the DesiredLRP matching the given process guid
	RemoveDesiredLRP(processGuid string) error

	// Lists all Tasks
	Tasks() ([]*models.Task, error)

	// Lists all Tasks of the given domain
	TasksByDomain(domain string) ([]*models.Task, error)

	// Lists all Tasks on the given cell
	TasksByCellID(cellId string) ([]*models.Task, error)

	// Returns the Task with the given guid
	TaskByGuid(guid string) (*models.Task, error)

	// Creates a Task from the given TaskDefinition
	DesireTask(guid, domain string, def *models.TaskDefinition) error

	// Cancels the Task with the given task guid
	CancelTask(taskGuid string) error

	// Returns an EventSource for watching changes to LRPs
	SubscribeToEvents() (events.EventSource, error)
}

The External Client can be used to access the BBS's public functionality. It exposes methods for basic LRP and Task Lifecycles, Domain manipulation, and event subscription.

type ServiceClient

type ServiceClient interface {
	CellById(logger lager.Logger, cellId string) (*models.CellPresence, error)
	Cells(logger lager.Logger) (models.CellSet, error)
	CellEvents(logger lager.Logger) <-chan models.CellEvent
	NewCellPresenceRunner(logger lager.Logger, cellPresence *models.CellPresence, retryInterval time.Duration) ifrit.Runner
	NewBBSLockRunner(logger lager.Logger, bbsPresence *models.BBSPresence, retryInterval time.Duration) (ifrit.Runner, error)
	CurrentBBS(logger lager.Logger) (*models.BBSPresence, error)
	CurrentBBSURL(logger lager.Logger) (string, error)
}

func NewServiceClient

func NewServiceClient(session *consuladapter.Session, clock clock.Clock) ServiceClient

Directories

Path Synopsis
cmd
bbs
db
etcd/fakes
This file was generated by counterfeiter
This file was generated by counterfeiter
fakes
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter
fakes
This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter
eventfakes
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter
fakes
This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter
migrationfakes
This file was generated by counterfeiter
This file was generated by counterfeiter
Package models is a generated protocol buffer package.
Package models is a generated protocol buffer package.
fakes
This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter
fakes
This file was generated by counterfeiter
This file was generated by counterfeiter

Jump to

Keyboard shortcuts

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