Exemplo n.º 1
0
func dial(addr string) *doozer.Conn {
	c, err := doozer.Dial(addr)
	if err != nil {
		panic(err)
	}
	return c
}
Exemplo n.º 2
0
func DoozerConnect() *doozer.Conn {
	doozerConn, err := doozer.Dial(*DoozerServer)
	if err != nil {
		log.Panic(err.Error())
	}

	return doozerConn
}
Exemplo n.º 3
0
// IsCal checks if addr is a CAL in the cluster named name.
// Returns a client if so, nil if not.
func isCal(name, addr string) (*doozer.Conn, error) {
	c, err := doozer.Dial(addr)
	if err != nil {
		return nil, err
	}

	err = c.Access(rwsk)
	if err != nil {
		return nil, err
	}

	v, _, _ := c.Get("/ctl/name", nil)
	if string(v) != name {
		return nil, nil
	}

	rev, err := c.Rev()
	if err != nil {
		return nil, err
	}

	var cals []string
	names, err := c.Getdir("/ctl/cal", rev, 0, -1)
	if err != nil {
		return nil, err
	}
	for _, name := range names {
		cals = append(cals, name)
	}

	for _, cal := range cals {
		body, _, err := c.Get("/ctl/cal/"+cal, nil)
		if err != nil || len(body) == 0 {
			continue
		}

		id := string(body)

		v, _, err := c.Get("/ctl/node/"+id+"/addr", nil)
		if err != nil {
			return nil, err
		}
		if string(v) == addr {
			return c, nil
		}
	}

	return nil, nil
}
Exemplo n.º 4
0
func (d *doozerConnection) dial(server string, boot string) (bool, error) {
	var err error

	d.Connection, err = doozer.Dial(server)
	if err != nil {
		return false, err
	}

	d.currentInstance = server
	//d.Log.Println("Connected to Doozer Instance: " + server)
	d.Log.Item(DoozerConnected{
		Addr: server,
	})

	return true, nil
}
Exemplo n.º 5
0
// only call from mux()
func (d *DoozerConnection) dialMux(server string, boot string) error {
	var err error

	d.connection, err = doozer.Dial(server)
	if err != nil {
		return err
	}

	d.currentInstance = server
	//d.Log.Println("Connected to Doozer Instance: " + server)
	d.Log.Item(DoozerConnected{
		Addr: server,
	})

	return nil
}
Exemplo n.º 6
0
// only call from mux()
func (d *DoozerConnection) dialMux(server string, boot string) error {
	var err error

	d.connection, err = doozer.Dial(server)
	if err != nil {
		return err
	}

	d.currentInstance = server
	//d.Log.Println("Connected to Doozer Instance: " + server)
	connected := DoozerConnected{Addr: server}
	// Log connection
	d.Log.Trace(fmt.Sprintf("%T: %+v", connected, connected))

	return nil
}
Exemplo n.º 7
0
func Dial(addr string) (*Conn, error) {
	conn, err := doozer.Dial(addr)
	return &Conn{Conn: conn, Id: "1"}, err
}