brokerapi

package
v0.0.0-...-157ed56 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2014 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MYSQL    = 1
	SQLITE   = 2
	POSTGRES = 3
)
View Source
const (
	// Raised by Broker Service if service instance or service instance binding already exists
	ErrCodeConflict = 10
	// Raised by Broker Service if service instance or service instance binding cannot be found
	ErrCodeGone = 20
	// Raised by Broker Service for any other issues
	ErrCodeOther = 99
)

Variables

This section is empty.

Functions

func MarshalIntArray

func MarshalIntArray(inta []int) []byte

func New

func New(o Options, am AgentManagerInterface) *broker

func UnmarshalIntArray

func UnmarshalIntArray(ba []byte) []int

Types

type AgentManagerInterface

type AgentManagerInterface interface {
	Ping(ServiceAgent) error

	Catalog() (Catalog, error)

	GetServiceAgent(instanceid string) (BrokerService, error)

	AddImage(string, ImageDefinition) error
	GetImage(string, string) ([]ImageDefinition, error)
	DeleteImage(string, string) error

	AddCerts(BrokerCerts) error
	GetCerts(string) ([]BrokerCerts, error)
	DeleteCerts(string) error
}

type BindingRequest

type BindingRequest struct {
	InstanceId string `json:"-"`
	BindingId  string `json:"-"`
	ServiceId  string `json:"service_id"`
	PlanId     string `json:"plan_id"`
	AppId      string `json:"app_guid"`
}

See http://docs.cloudfoundry.com/docs/running/architecture/services/api.html#binding

type BrokerCerts

type BrokerCerts struct {
	Host       string
	ClientCert []byte
	ClientKey  []byte
	CA         []byte
}

type BrokerError

type BrokerError struct {
	Description string `json:"description"`
}

Other types

type BrokerService

type BrokerService interface {

	// Exposes the catalog of services managed by this broker.
	// Returns the exposed catalog.
	Catalog() (Catalog, error)

	// Creates a service instance of a specified service and plan.
	// Returns the optional management URL.
	Provision(ProvisioningRequest) (string, error)

	// Removes created service instance.
	Deprovision(ProvisioningRequest) error

	// Binds to specified service instance.
	// Returns  credentials necessary to establish connection to this
	// service instance as well as optional syslog drain URL.
	Bind(BindingRequest) (string, Credentials, string, error)

	// Removes created binding.
	Unbind(BindingRequest) error
}

The BrokerService defines the internal API used by the broker's HTTP endpoints.

type BrokerServiceError

type BrokerServiceError interface {
	Code() int
	Error() string
}

type Credentials

type Credentials map[string]interface{}

type DispatcherInterface

type DispatcherInterface interface {
	//algorithm implementation to find best ServiceAgent for provisioning
	NewBrokerService() (BrokerService, error)
}

type DockerInfo

type DockerInfo struct {
	Containers     int
	Images         int
	Debug          int
	NFd            int
	NGoroutines    int
	MemoryLimit    int
	SwapLimit      int
	IPv4Forwarding int
}

type ImageDefinition

type ImageDefinition struct {
	Name          string
	Plan          string
	DashBoardUrl  map[string]interface{}
	Credentials   map[string]interface{}
	Numinstances  int
	Containername string
}

type Options

type Options struct {
	Host     string
	Port     int
	Username string
	Password string
	Debug    bool
	LogFile  string
	Trace    bool
	PidFile  string
}

type Persister

type Persister struct {
	Driver   string
	Host     string
	Port     int
	User     string
	Password string
	Database string
	Db       *sql.DB
}

func (*Persister) AddBasicImageConf

func (persister *Persister) AddBasicImageConf(service_id int, name, plan string) error

func (*Persister) AddBrokerCertsConf

func (persister *Persister) AddBrokerCertsConf(agent string, clientcertfile, clientkeyfile, cafile []byte) error

func (*Persister) AddImageConf

func (persister *Persister) AddImageConf(service_id int, name, plan, dashboardurl, credentials string, numinstances int, containername string) error

func (*Persister) AddServiceAgents

func (persister *Persister) AddServiceAgents(serviceagents []ServiceAgent) error

func (*Persister) AddServiceBinding

func (persister *Persister) AddServiceBinding(instanceId, bindingId, appId string, started_at time.Time) error

func (*Persister) AddServiceConf

func (persister *Persister) AddServiceConf(user, password, catalog string) error

func (*Persister) AddServiceInstance

func (persister *Persister) AddServiceInstance(service_name string, service_port, host_port int,
	service_url, container_id, service_agent, container_name, image_name string,
	pr ProvisioningRequest, started_at time.Time) error

func (*Persister) AddorUpdateServiceAgent

func (persister *Persister) AddorUpdateServiceAgent(sa ServiceAgent) error

func (*Persister) Connect

func (persister *Persister) Connect() error

func (*Persister) DeleteBrokerCertsConf

func (persister *Persister) DeleteBrokerCertsConf(agent string) error

func (*Persister) DeleteImageConf

func (persister *Persister) DeleteImageConf(service_id int, name, plan string) error

func (*Persister) DeleteServiceBinding

func (persister *Persister) DeleteServiceBinding(instanceId, bindingId string) error

func (*Persister) DeleteServiceConf

func (persister *Persister) DeleteServiceConf(id int) error

func (*Persister) DeleteServiceInstance

func (persister *Persister) DeleteServiceInstance(instanceId string) error

func (*Persister) GetBrokerCerts

func (persister *Persister) GetBrokerCerts() ([]BrokerCerts, error)

func (*Persister) GetContainerIdAndImageName

func (persister *Persister) GetContainerIdAndImageName(instanceid string) (string, string)

func (*Persister) GetCount

func (persister *Persister) GetCount(tablename, cond string) (int32, error)

func (*Persister) GetPortBindings

func (persister *Persister) GetPortBindings(cond string) (int, int, []int, error)

func (*Persister) GetServiceAgentFromInstance

func (persister *Persister) GetServiceAgentFromInstance(cond string) (string, error)

func (*Persister) GetServiceAgentList

func (persister *Persister) GetServiceAgentList(cond string) ([]ServiceAgent, error)

func (*Persister) GetServiceConf

func (persister *Persister) GetServiceConf() ([]ServiceDefinition, error)

func (*Persister) GetServiceId

func (persister *Persister) GetServiceId(catalog string) int

func (*Persister) GetServicePort

func (persister *Persister) GetServicePort(instanceid string) int

func (*Persister) GetServiceUrl

func (persister *Persister) GetServiceUrl(cond string) string

func (*Persister) HasEntry

func (persister *Persister) HasEntry(tablename, cond string) bool

func (*Persister) InsertTable

func (persister *Persister) InsertTable(tablename string, colmap map[string]interface{}) error

func (*Persister) MarkServiceAgentActive

func (persister *Persister) MarkServiceAgentActive(Host string) error

func (*Persister) MarkServiceAgentInactive

func (persister *Persister) MarkServiceAgentInactive(Host string) error

func (*Persister) ReadContainers

func (persister *Persister) ReadContainers(container_map map[string]string) error

func (*Persister) TimeElapsed

func (persister *Persister) TimeElapsed(eventtime string) string

func (*Persister) UpdateTable

func (persister *Persister) UpdateTable(tablename string, colmap map[string]interface{}, cond string) error

func (*Persister) UrlString4MySQL

func (persister *Persister) UrlString4MySQL() string

func (*Persister) UrlString4Postgres

func (persister *Persister) UrlString4Postgres() string

func (*Persister) WritePortBinding

func (persister *Persister) WritePortBinding(ports []int, cond string) error

type Plan

type Plan struct {
	Id          string                 `json:"id"`
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
}

See http://docs.cloudfoundry.com/docs/running/architecture/services/api.html#catalog-mgmt

type ProvisioningRequest

type ProvisioningRequest struct {
	InstanceId string `json:"-"`
	ServiceId  string `json:"service_id"`
	PlanId     string `json:"plan_id"`
	OrgId      string `json:"organization_guid"`
	SpaceId    string `json:"space_guid"`
}

See http://docs.cloudfoundry.com/docs/running/architecture/services/api.html#provisioning

type Service

type Service struct {
	Id          string                 `json:"id"`
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Bindable    bool                   `json:"bindable"`
	Tags        []string               `json:"tags,omitempty"`
	Requires    []string               `json:"requires,omitempty"`
	Plans       []Plan                 `json:"plans"`
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
}

See http://docs.cloudfoundry.com/docs/running/architecture/services/api.html#catalog-mgmt

type ServiceAgent

type ServiceAgent struct {
	ServiceHost  string
	DockerHost   string
	DockerPort   int
	LastPing     time.Time
	IsActive     bool
	PerfFactor   float32
	KeepAlive    int
	ExecCommand  string
	ExecArgs     string
	Portbind_min int
	Portbind_max int
	Portbindings []uint8
}

type ServiceDefinition

type ServiceDefinition struct {
	User     string
	Password string
	Catalog  string
	Images   []ImageDefinition
}

type Version

type Version struct {
	Version   string
	GitCommit string
	GoVersion string
}

Jump to

Keyboard shortcuts

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