store

package
v0.0.0-...-4402e7d Latest Latest
Warning

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

Go to latest
Published: May 27, 2016 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HostLabel  = "host"
	StateLabel = "state"
	RuleLabel  = "rule"
)

Variables

This section is empty.

Functions

func WatchServicesIndirectStartFunc

func WatchServicesIndirectStartFunc(store Store, opts QueryServiceOptions, cb func(update ServiceUpdate, stop <-chan struct{})) daemon.StartFunc

func WatchServicesStartFunc

func WatchServicesStartFunc(store Store, opts QueryServiceOptions, updates chan<- ServiceUpdate) daemon.StartFunc

Types

type Cluster

type Cluster interface {
	Heartbeat(ttl time.Duration) error
	EndSession() error
}

type ContainerRule

type ContainerRule struct {
	Selector     Selector `json:"selector,omitempty"`
	InstancePort int      `json:"instancePort,omitempty"`
}

Specifies how containers should be selected as instances, and the attributes of the resulting instances.

func (*ContainerRule) Includes

func (spec *ContainerRule) Includes(s Labeled) bool

type Host

type Host struct {
	IP net.IP `json:"address"`
}

type HostChange

type HostChange struct {
	Name         string
	HostDeparted bool
}

type IngressInstance

type IngressInstance struct {
	Weight int `json:"weight"`
}

type Instance

type Instance struct {
	Host          Host              `json:"host"`
	ContainerRule string            `json:"containerRule"`
	Address       *netutil.IPPort   `json:"address,omitempty"`
	Labels        map[string]string `json:"labels"`
}

func (Instance) Label

func (inst Instance) Label(k string) string

type Labeled

type Labeled interface {
	Label(string) string
}

type QueryServiceOptions

type QueryServiceOptions struct {
	WithInstances        bool
	WithContainerRules   bool
	WithIngressInstances bool
}

type Selector

type Selector map[string]string

func (Selector) Empty

func (sel Selector) Empty() bool

func (Selector) Includes

func (sel Selector) Includes(s Labeled) bool

type Service

type Service struct {
	Address      *netutil.IPPort `json:"address,omitempty"`
	InstancePort int             `json:"instancePort,omitempty"`
	Protocol     string          `json:"protocol,omitempty"`
}

type ServiceChange

type ServiceChange struct {
	Name           string
	ServiceDeleted bool
}

type ServiceInfo

type ServiceInfo struct {
	Service
	Instances        map[string]Instance
	ContainerRules   map[string]ContainerRule
	IngressInstances map[netutil.IPPort]IngressInstance
}

type ServiceUpdate

type ServiceUpdate struct {
	Services map[string]*ServiceInfo
	Reset    bool
}

type Store

type Store interface {
	Cluster

	Ping() error

	RegisterHost(identity string, details *Host) error
	DeregisterHost(identity string) error
	GetHosts() ([]*Host, error)
	WatchHosts(ctx context.Context, resCh chan<- HostChange, errorSink daemon.ErrorSink)

	CheckRegisteredService(serviceName string) error
	AddService(name string, service Service) error
	RemoveService(serviceName string) error
	RemoveAllServices() error

	GetService(serviceName string, opts QueryServiceOptions) (*ServiceInfo, error)
	GetAllServices(opts QueryServiceOptions) (map[string]*ServiceInfo, error)

	SetContainerRule(serviceName string, ruleName string, spec ContainerRule) error
	RemoveContainerRule(serviceName string, ruleName string) error

	AddInstance(serviceName, instanceName string, details Instance) error
	RemoveInstance(serviceName, instanceName string) error

	AddIngressInstance(serviceName string, addr netutil.IPPort, details IngressInstance) error
	RemoveIngressInstance(serviceName string, addr netutil.IPPort) error

	WatchServices(ctx context.Context, resCh chan<- ServiceChange, errorSink daemon.ErrorSink, opts QueryServiceOptions)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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