Ejemplo n.º 1
0
func (s *LBRegistrySuite) SetUpSuite(c *C) {
	machines := []string{"http://127.0.0.1:4001"}
	s.client = etcd.NewClient(machines)
	s.client.Delete("customkey", true)

	s.registry, _ = NewLBRegistry("customkey", 15)
	s.appRegistration = &AppRegistration{Name: "name", Host: "host", Port: 12345}
	s.handlerRegistration = &HandlerRegistration{
		Name:        "name",
		Host:        "host",
		Path:        "/path/to/server",
		Methods:     []string{"PUT"},
		Middlewares: []middleware.Middleware{middleware.Middleware{Type: "test", ID: "id", Spec: "hi"}},
	}
}
Ejemplo n.º 2
0
func NewEtcdBackend(nodes []string, etcdKey, consistency string) (*EtcdBackend, error) {
	client := etcd.NewClient(nodes)
	if err := client.SetConsistency(consistency); err != nil {
		return nil, err
	}
	b := &EtcdBackend{
		nodes:       nodes,
		etcdKey:     etcdKey,
		consistency: consistency,
		client:      client,
		cancelC:     make(chan bool, 1),
		stopC:       make(chan bool, 1),
	}
	return b, nil
}
Ejemplo n.º 3
0
func (s *ClientSuite) SetUpSuite(c *C) {
	machines := []string{"http://127.0.0.1:4001"}
	s.etcd = etcd.NewClient(machines)
	s.client = NewClient("clienttest")
}
Ejemplo n.º 4
0
func NewRegistry(config Config) *Registry {
	return &Registry{
		etcdClient: etcd.NewClient([]string{"http://127.0.0.1:4001"}),
		config:     config,
	}
}
Ejemplo n.º 5
0
func NewClient(key string) *Client {
	etcd := etcd.NewClient([]string{etcdMachine})

	return &Client{Key: key, etcd: etcd}
}