agent

package
v0.0.0-...-ec3793a Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2014 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeartbeatIntervalSecs = 5
	MissedHearbeatTTL     = 5
)
View Source
const KeyPrefix = "/discover"

Variables

View Source
var Attempts = attempt.Strategy{
	Min:   5,
	Total: 5 * time.Second,
	Delay: 200 * time.Millisecond,
}

Attempts is the attempt strategy that is used to connect to etcd.

Functions

func ListenAndServe

func ListenAndServe(server *Agent) error

Types

type Agent

type Agent struct {
	Backend DiscoveryBackend
	Address string
}

func NewServer

func NewServer(addr string, etcdAddrs []string) *Agent

func (*Agent) Register

func (s *Agent) Register(args *Args, ret *string) error

func (*Agent) Subscribe

func (s *Agent) Subscribe(args *Args, stream rpcplus.Stream) error

func (*Agent) Unregister

func (s *Agent) Unregister(args *Args, ret *struct{}) error

type Args

type Args struct {
	Name  string
	Addr  string
	Attrs map[string]string
}

type DiscoveryBackend

type DiscoveryBackend interface {
	Subscribe(name string) (UpdateStream, error)
	Register(name string, addr string, attrs map[string]string) error
	Unregister(name string, addr string) error
}

type EtcdBackend

type EtcdBackend struct {
	Client *etcd.Client
}

func (*EtcdBackend) Register

func (b *EtcdBackend) Register(name, addr string, attrs map[string]string) error

func (*EtcdBackend) Subscribe

func (b *EtcdBackend) Subscribe(name string) (UpdateStream, error)

func (*EtcdBackend) Unregister

func (b *EtcdBackend) Unregister(name, addr string) error

type ServiceUpdate

type ServiceUpdate struct {
	Name    string
	Addr    string
	Online  bool
	Attrs   map[string]string
	Created uint
}

type UpdateStream

type UpdateStream interface {
	Chan() chan *ServiceUpdate
	Close()
}

Jump to

Keyboard shortcuts

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