service

package
v0.0.0-...-5facc9d Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2013 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrServiceInstanceNotFound = stderrors.New("Service instance not found")
	ErrInvalidInstanceName     = stderrors.New("Invalid service instance name")
	ErrAccessNotAllowed        = stderrors.New("User does not have access to this service instance")
)

Functions

func CreateServiceInstance

func CreateServiceInstance(name string, service *Service, user *auth.User) error

func DeleteInstance

func DeleteInstance(si *ServiceInstance) error

DeleteInstance deletes the service instance from the database.

func GetServicesNames

func GetServicesNames(services []Service) []string

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func (*Client) Bind

func (c *Client) Bind(instance *ServiceInstance, app bind.App, unit bind.Unit) (map[string]string, error)

func (*Client) Create

func (c *Client) Create(instance *ServiceInstance) error

func (*Client) Destroy

func (c *Client) Destroy(instance *ServiceInstance) error

func (*Client) Info

func (c *Client) Info(instance *ServiceInstance) ([]map[string]string, error)

Info returns the additional info about a service instance. The api should be prepared to receive the request, like below: GET /resources/<name>

func (*Client) Status

func (c *Client) Status(instance *ServiceInstance) (string, error)

Connects into service's api The api should be prepared to receive the request, like below: GET /resources/<name>/status/ The service host here is the private ip of the service instance 204 means the service is up, 500 means the service is down

func (*Client) Unbind

func (c *Client) Unbind(instance *ServiceInstance, unit bind.Unit) error

type Service

type Service struct {
	Name         string `bson:"_id"`
	Endpoint     map[string]string
	OwnerTeams   []string `bson:"owner_teams"`
	Teams        []string
	Status       string
	Doc          string
	IsRestricted bool `bson:"is_restricted"`
}

func GetServicesByOwnerTeams

func GetServicesByOwnerTeams(teamKind string, u *auth.User) ([]Service, error)

func GetServicesByTeamKindAndNoRestriction

func GetServicesByTeamKindAndNoRestriction(teamKind string, u *auth.User) ([]Service, error)

func (*Service) Create

func (s *Service) Create() error

func (*Service) Delete

func (s *Service) Delete() error

func (*Service) Get

func (s *Service) Get() error

func (*Service) GrantAccess

func (s *Service) GrantAccess(team *auth.Team) error

func (*Service) HasTeam

func (s *Service) HasTeam(team *auth.Team) bool

func (*Service) RevokeAccess

func (s *Service) RevokeAccess(team *auth.Team) error

func (*Service) Update

func (s *Service) Update() error

type ServiceInstance

type ServiceInstance struct {
	Name        string
	ServiceName string `bson:"service_name"`
	Apps        []string
	Teams       []string
}

func GetServiceInstance

func GetServiceInstance(name string, u *auth.User) (*ServiceInstance, error)

func GetServiceInstancesByServices

func GetServiceInstancesByServices(services []Service) ([]ServiceInstance, error)

func GetServiceInstancesByServicesAndTeams

func GetServiceInstancesByServicesAndTeams(services []Service, u *auth.User) ([]ServiceInstance, error)

func (*ServiceInstance) AddApp

func (si *ServiceInstance) AddApp(appName string) error

func (*ServiceInstance) BindApp

func (si *ServiceInstance) BindApp(app bind.App) error

BindApp makes the bind between the service instance and an app.

func (*ServiceInstance) BindUnit

func (si *ServiceInstance) BindUnit(app bind.App, unit bind.Unit) (map[string]string, error)

BindUnit makes the bind between the binder and an unit.

func (*ServiceInstance) Create

func (si *ServiceInstance) Create() error

func (*ServiceInstance) FindApp

func (si *ServiceInstance) FindApp(appName string) int

func (*ServiceInstance) Info

func (si *ServiceInstance) Info() (map[string]string, error)

func (*ServiceInstance) MarshalJSON

func (si *ServiceInstance) MarshalJSON() ([]byte, error)

MarshalJSON marshals the ServiceName in json format.

func (*ServiceInstance) RemoveApp

func (si *ServiceInstance) RemoveApp(appName string) error

func (*ServiceInstance) Service

func (si *ServiceInstance) Service() *Service

func (*ServiceInstance) Status

func (si *ServiceInstance) Status() (string, error)

Status returns the service instance status.

func (*ServiceInstance) UnbindApp

func (si *ServiceInstance) UnbindApp(app bind.App) error

UnbindApp makes the unbind between the service instance and an app.

func (*ServiceInstance) UnbindUnit

func (si *ServiceInstance) UnbindUnit(unit bind.Unit) error

UnbindUnit makes the unbind between the service instance and an unit.

type ServiceModel

type ServiceModel struct {
	Service   string   `json:"service"`
	Instances []string `json:"instances"`
}

Jump to

Keyboard shortcuts

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