config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2015 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTTL = 60
)

Variables

This section is empty.

Functions

This section is empty.

Types

type App added in v0.6.0

type App interface {
	Name() string
	Env() map[string]string
	EnvSet(key, value string)
	EnvGet(key string) string
	Version() string
	SetVersion(version string)
	VersionID() string
	SetVersionID(versionID string)
	Ports() map[string]string
	ClearPorts()
	AddPort(port, portType string)
	ID() int64
	ContainerName() string
	SetProcesses(pool string, count int)
	GetProcesses(pool string) int
	RuntimePools() []string
	SetMemory(pool string, mem string)
	GetMemory(pool string) string
	SetCPUShares(pool string, cpu string)
	GetCPUShares(pool string) string
}

Interface to wrap AppConfig, so that it can be swapped out with a different Backend. This should be temporary as many of these methods won't be useful.

func NewAppConfig

func NewAppConfig(app, version string) App

func NewAppConfigWithEnv

func NewAppConfigWithEnv(app, version string, env map[string]string) App

type AppConfig

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

func (*AppConfig) AddPort

func (s *AppConfig) AddPort(port, portType string)

func (*AppConfig) ClearPorts

func (s *AppConfig) ClearPorts()

func (*AppConfig) ContainerName

func (s *AppConfig) ContainerName() string

func (*AppConfig) Env

func (s *AppConfig) Env() map[string]string

Env returns a map representing the runtime environment for the container. Changes to this map have no effect.

func (*AppConfig) EnvGet

func (s *AppConfig) EnvGet(key string) string

func (*AppConfig) EnvSet

func (s *AppConfig) EnvSet(key, value string)

func (*AppConfig) GetCPUShares

func (s *AppConfig) GetCPUShares(pool string) string

func (*AppConfig) GetMemory

func (s *AppConfig) GetMemory(pool string) string

func (*AppConfig) GetProcesses

func (s *AppConfig) GetProcesses(pool string) int

func (*AppConfig) ID

func (s *AppConfig) ID() int64

func (*AppConfig) Name

func (s *AppConfig) Name() string

func (*AppConfig) Ports

func (s *AppConfig) Ports() map[string]string

func (*AppConfig) RuntimePools

func (s *AppConfig) RuntimePools() []string

func (*AppConfig) SetCPUShares

func (s *AppConfig) SetCPUShares(pool string, cpu string)

func (*AppConfig) SetMemory

func (s *AppConfig) SetMemory(pool string, mem string)

func (*AppConfig) SetProcesses

func (s *AppConfig) SetProcesses(pool string, count int)

func (*AppConfig) SetVersion

func (s *AppConfig) SetVersion(version string)

func (*AppConfig) SetVersionID

func (s *AppConfig) SetVersionID(versionID string)

func (*AppConfig) Version

func (s *AppConfig) Version() string

func (*AppConfig) VersionID

func (s *AppConfig) VersionID() string

type Backend

type Backend interface {
	// Apps
	AppExists(app, env string) (bool, error)
	CreateApp(app, env string) (bool, error)
	ListApps(env string) ([]App, error)
	GetApp(app, env string) (App, error)
	UpdateApp(svcCfg App, env string) (bool, error)
	DeleteApp(svcCfg App, env string) (bool, error)

	// Pools
	AssignApp(app, env, pool string) (bool, error)
	UnassignApp(app, env, pool string) (bool, error)
	ListAssignments(env, pool string) ([]string, error)
	CreatePool(env, pool string) (bool, error)
	DeletePool(env, pool string) (bool, error)
	ListPools(env string) ([]string, error)

	// Envs
	ListEnvs() ([]string, error)

	// Host
	UpdateHost(env, pool string, host HostInfo) error
	ListHosts(env, pool string) ([]HostInfo, error)
	DeleteHost(env, pool string, host HostInfo) error

	//Pub/Sub
	Subscribe(key string) chan string
	Notify(key, value string) (int, error)

	// TODO: still merging these backends
	// these are brought in from the RegistryBackend
	// Keys
	Keys(key string) ([]string, error)
	Delete(key string) (int, error)
	Expire(key string, ttl uint64) (int, error)
	TTL(key string) (int, error)

	// Maps
	Set(key, field string, value string) (string, error)
	Get(key, field string) (string, error)
	// contains filtered or unexported methods
}

type ConfigChange

type ConfigChange struct {
	AppConfig App
	Restart   bool
	Error     error
}

type HostInfo

type HostInfo struct {
	HostIP string
}

type MemoryBackend

type MemoryBackend struct {
	AppExistsFunc       func(app, env string) (bool, error)
	CreateAppFunc       func(app, env string) (bool, error)
	GetAppFunc          func(app, env string) (App, error)
	UpdateAppFunc       func(svcCfg App, env string) (bool, error)
	DeleteAppFunc       func(svcCfg App, env string) (bool, error)
	ListAppFunc         func(env string) ([]AppConfig, error)
	AssignAppFunc       func(app, env, pool string) (bool, error)
	UnassignAppFunc     func(app, env, pool string) (bool, error)
	ListAssignmentsFunc func(env, pool string) ([]string, error)
	CreatePoolFunc      func(env, pool string) (bool, error)
	DeletePoolFunc      func(env, pool string) (bool, error)
	ListPoolsFunc       func(env string) ([]string, error)
	ListEnvsFunc        func() ([]string, error)
	ListHostsFunc       func(env, pool string) ([]HostInfo, error)

	MembersFunc      func(key string) ([]string, error)
	KeysFunc         func(key string) ([]string, error)
	AddMemberFunc    func(key, value string) (int, error)
	RemoveMemberFunc func(key, value string) (int, error)
	NotifyFunc       func(key, value string) (int, error)
	SetMultiFunc     func(key string, values map[string]string) (string, error)
	// contains filtered or unexported fields
}

func NewMemoryBackend

func NewMemoryBackend() *MemoryBackend

func (*MemoryBackend) AddMember

func (r *MemoryBackend) AddMember(key, value string) (int, error)

func (*MemoryBackend) AppExists

func (r *MemoryBackend) AppExists(app, env string) (bool, error)

func (*MemoryBackend) AssignApp

func (r *MemoryBackend) AssignApp(app, env, pool string) (bool, error)

func (*MemoryBackend) CreateApp

func (r *MemoryBackend) CreateApp(app, env string) (bool, error)

func (*MemoryBackend) CreatePool

func (r *MemoryBackend) CreatePool(env, pool string) (bool, error)

func (*MemoryBackend) Delete

func (r *MemoryBackend) Delete(key string) (int, error)

func (*MemoryBackend) DeleteApp

func (r *MemoryBackend) DeleteApp(svcCfg App, env string) (bool, error)

func (*MemoryBackend) DeleteHost

func (r *MemoryBackend) DeleteHost(env, pool string, host HostInfo) error

func (*MemoryBackend) DeleteMulti

func (r *MemoryBackend) DeleteMulti(key string, fields ...string) (int, error)

func (*MemoryBackend) DeletePool

func (r *MemoryBackend) DeletePool(env, pool string) (bool, error)

func (*MemoryBackend) Expire

func (r *MemoryBackend) Expire(key string, ttl uint64) (int, error)

func (*MemoryBackend) Get

func (r *MemoryBackend) Get(key, field string) (string, error)

func (*MemoryBackend) GetAll

func (r *MemoryBackend) GetAll(key string) (map[string]string, error)

func (*MemoryBackend) GetApp

func (r *MemoryBackend) GetApp(app, env string) (App, error)

func (*MemoryBackend) Keys

func (r *MemoryBackend) Keys(key string) ([]string, error)

func (*MemoryBackend) ListApps

func (r *MemoryBackend) ListApps(env string) ([]App, error)

func (*MemoryBackend) ListAssignments

func (r *MemoryBackend) ListAssignments(env, pool string) ([]string, error)

func (*MemoryBackend) ListEnvs

func (r *MemoryBackend) ListEnvs() ([]string, error)

func (*MemoryBackend) ListHosts

func (r *MemoryBackend) ListHosts(env, pool string) ([]HostInfo, error)

func (*MemoryBackend) ListPools

func (r *MemoryBackend) ListPools(env string) ([]string, error)

func (*MemoryBackend) Members

func (r *MemoryBackend) Members(key string) ([]string, error)

func (*MemoryBackend) Notify

func (r *MemoryBackend) Notify(key, value string) (int, error)

func (*MemoryBackend) RemoveMember

func (r *MemoryBackend) RemoveMember(key, value string) (int, error)

func (*MemoryBackend) Set

func (r *MemoryBackend) Set(key, field string, value string) (string, error)

func (*MemoryBackend) SetMulti

func (r *MemoryBackend) SetMulti(key string, values map[string]string) (string, error)

func (*MemoryBackend) Subscribe

func (r *MemoryBackend) Subscribe(key string) chan string

func (*MemoryBackend) TTL added in v0.6.0

func (r *MemoryBackend) TTL(key string) (int, error)

func (*MemoryBackend) UnassignApp

func (r *MemoryBackend) UnassignApp(app, env, pool string) (bool, error)

func (*MemoryBackend) UpdateApp

func (r *MemoryBackend) UpdateApp(svcCfg App, env string) (bool, error)

func (*MemoryBackend) UpdateHost

func (r *MemoryBackend) UpdateHost(env, pool string, host HostInfo) error

type RedisBackend

type RedisBackend struct {
	RedisHost string
	// contains filtered or unexported fields
}

func (*RedisBackend) AddMember

func (r *RedisBackend) AddMember(key, value string) (int, error)

func (*RedisBackend) AppExists

func (r *RedisBackend) AppExists(app, env string) (bool, error)

func (*RedisBackend) AssignApp

func (r *RedisBackend) AssignApp(app, env, pool string) (bool, error)

func (*RedisBackend) CreateApp

func (r *RedisBackend) CreateApp(app, env string) (bool, error)

func (*RedisBackend) CreatePool

func (r *RedisBackend) CreatePool(env, pool string) (bool, error)

func (*RedisBackend) Delete

func (r *RedisBackend) Delete(key string) (int, error)

func (*RedisBackend) DeleteApp

func (r *RedisBackend) DeleteApp(svcCfg App, env string) (bool, error)

func (*RedisBackend) DeleteHost

func (r *RedisBackend) DeleteHost(env, pool string, host HostInfo) error

func (*RedisBackend) DeleteMulti

func (r *RedisBackend) DeleteMulti(key string, fields ...string) (int, error)

func (*RedisBackend) DeletePool

func (r *RedisBackend) DeletePool(env, pool string) (bool, error)

func (*RedisBackend) Expire

func (r *RedisBackend) Expire(key string, ttl uint64) (int, error)

func (*RedisBackend) GcVMap

func (r *RedisBackend) GcVMap(key string, vmap *utils.VersionedMap) error

func (*RedisBackend) Get

func (r *RedisBackend) Get(key, field string) (string, error)

func (*RedisBackend) GetAll

func (r *RedisBackend) GetAll(key string) (map[string]string, error)

func (*RedisBackend) GetApp

func (r *RedisBackend) GetApp(app, env string) (App, error)

func (*RedisBackend) Keys

func (r *RedisBackend) Keys(key string) ([]string, error)

func (*RedisBackend) ListApps

func (r *RedisBackend) ListApps(env string) ([]App, error)

func (*RedisBackend) ListAssignments

func (r *RedisBackend) ListAssignments(env, pool string) ([]string, error)

func (*RedisBackend) ListEnvs

func (r *RedisBackend) ListEnvs() ([]string, error)

func (*RedisBackend) ListHosts

func (r *RedisBackend) ListHosts(env, pool string) ([]HostInfo, error)

func (*RedisBackend) ListPools

func (r *RedisBackend) ListPools(env string) ([]string, error)

func (*RedisBackend) LoadVMap

func (r *RedisBackend) LoadVMap(key string, dest *utils.VersionedMap) error

func (*RedisBackend) Members

func (r *RedisBackend) Members(key string) ([]string, error)

func (*RedisBackend) Notify

func (r *RedisBackend) Notify(key, value string) (int, error)

func (*RedisBackend) RemoveMember

func (r *RedisBackend) RemoveMember(key, value string) (int, error)

func (*RedisBackend) SaveVMap

func (r *RedisBackend) SaveVMap(key string, vmap *utils.VersionedMap) error

func (*RedisBackend) Set

func (r *RedisBackend) Set(key, field string, value string) (string, error)

func (*RedisBackend) SetMulti

func (r *RedisBackend) SetMulti(key string, values map[string]string) (string, error)

func (*RedisBackend) Subscribe

func (r *RedisBackend) Subscribe(key string) chan string

func (*RedisBackend) TTL added in v0.6.0

func (r *RedisBackend) TTL(key string) (int, error)

func (*RedisBackend) UnassignApp

func (r *RedisBackend) UnassignApp(app, env, pool string) (bool, error)

func (*RedisBackend) UpdateApp

func (r *RedisBackend) UpdateApp(cfg App, env string) (bool, error)

func (*RedisBackend) UpdateHost

func (r *RedisBackend) UpdateHost(env, pool string, host HostInfo) error

type ServiceRegistration added in v0.6.0

type ServiceRegistration struct {
	Name          string            `json:"NAME,omitempty"`
	ExternalIP    string            `json:"EXTERNAL_IP,omitempty"`
	ExternalPort  string            `json:"EXTERNAL_PORT,omitempty"`
	InternalIP    string            `json:"INTERNAL_IP,omitempty"`
	InternalPort  string            `json:"INTERNAL_PORT,omitempty"`
	ContainerID   string            `json:"CONTAINER_ID"`
	ContainerName string            `json:"CONTAINER_NAME"`
	Image         string            `json:"IMAGE,omitempty"`
	ImageId       string            `json:"IMAGE_ID,omitempty"`
	StartedAt     time.Time         `json:"STARTED_AT"`
	Expires       time.Time         `json:"-"`
	Path          string            `json:"-"`
	VirtualHosts  []string          `json:"VIRTUAL_HOSTS"`
	Port          string            `json:"PORT"`
	ErrorPages    map[string]string `json:"ERROR_PAGES,omitempty"`
}

func (*ServiceRegistration) Equals added in v0.6.0

func (s *ServiceRegistration) Equals(other ServiceRegistration) bool

func (*ServiceRegistration) ExternalAddr added in v0.6.0

func (s *ServiceRegistration) ExternalAddr() string

func (*ServiceRegistration) InternalAddr added in v0.6.0

func (s *ServiceRegistration) InternalAddr() string

type Store

type Store struct {
	Backend Backend
	TTL     uint64
	// contains filtered or unexported fields
}

func NewStore

func NewStore(ttl uint64, registryURL string) *Store

func (*Store) AppExists

func (s *Store) AppExists(app, env string) (bool, error)

func (*Store) AssignApp

func (s *Store) AssignApp(app, env, pool string) (bool, error)

func (*Store) CheckForChangesNow

func (s *Store) CheckForChangesNow()

func (*Store) CreateApp

func (s *Store) CreateApp(app, env string) (bool, error)

func (*Store) CreatePool

func (s *Store) CreatePool(name, env string) (bool, error)

func (*Store) DeleteApp

func (s *Store) DeleteApp(app, env string) (bool, error)

func (*Store) DeleteHost

func (s *Store) DeleteHost(env, pool string, host HostInfo) error

func (*Store) DeletePool

func (s *Store) DeletePool(pool, env string) (bool, error)

func (*Store) EnvFor added in v0.6.0

func (s *Store) EnvFor(container *docker.Container) map[string]string

func (*Store) GetApp

func (s *Store) GetApp(app, env string) (App, error)

func (*Store) GetServiceRegistration added in v0.6.0

func (s *Store) GetServiceRegistration(env, pool, hostIP string, container *docker.Container) (*ServiceRegistration, error)

func (*Store) IsRegistered added in v0.6.0

func (s *Store) IsRegistered(env, pool, hostIP string, container *docker.Container) (bool, error)

func (*Store) ListApps

func (s *Store) ListApps(env string) ([]App, error)

func (*Store) ListAssignedPools

func (s *Store) ListAssignedPools(env, app string) ([]string, error)

func (*Store) ListAssignments

func (s *Store) ListAssignments(env, pool string) ([]string, error)

func (*Store) ListEnvs

func (s *Store) ListEnvs() ([]string, error)

func (*Store) ListHosts

func (s *Store) ListHosts(env, pool string) ([]HostInfo, error)

func (*Store) ListPools

func (s *Store) ListPools(env string) ([]string, error)

func (*Store) ListRegistrations added in v0.6.0

func (s *Store) ListRegistrations(env string) ([]ServiceRegistration, error)

TODO: get all ServiceRegistrations

func (*Store) NotifyEnvChanged

func (s *Store) NotifyEnvChanged(env string) error

func (*Store) NotifyRestart

func (s *Store) NotifyRestart(app, env string) error

func (*Store) PoolExists

func (s *Store) PoolExists(env, pool string) (bool, error)

func (*Store) RegisterService added in v0.6.0

func (s *Store) RegisterService(env, pool, hostIP string, container *docker.Container) (*ServiceRegistration, error)

func (*Store) UnRegisterService added in v0.6.0

func (s *Store) UnRegisterService(env, pool, hostIP string, container *docker.Container) (*ServiceRegistration, error)

func (*Store) UnassignApp

func (s *Store) UnassignApp(app, env, pool string) (bool, error)

func (*Store) UpdateApp

func (s *Store) UpdateApp(svcCfg App, env string) (bool, error)

func (*Store) UpdateHost

func (s *Store) UpdateHost(env, pool string, host HostInfo) error

func (*Store) Watch

func (s *Store) Watch(env string, stop chan struct{}) chan *ConfigChange

type Value

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

Jump to

Keyboard shortcuts

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