Ejemplo n.º 1
0
func EndPointForTablet(tablet *topo.Tablet) (*topo.EndPoint, error) {
	entry := topo.NewAddr(tablet.Alias.Uid, tablet.Hostname)
	if err := tablet.ValidatePortmap(); err != nil {
		return nil, err
	}

	// TODO(szopa): Rename _vtocc to vt.
	entry.NamedPortMap = map[string]int{
		"_vtocc": tablet.Portmap["vt"],
		"_mysql": tablet.Portmap["mysql"],
	}
	if port, ok := tablet.Portmap["vts"]; ok {
		entry.NamedPortMap["_vts"] = port
	}
	return entry, nil
}
Ejemplo n.º 2
0
func EndPointForTablet(tablet *topo.Tablet) (*topo.EndPoint, error) {
	host, port, err := netutil.SplitHostPort(tablet.Addr)
	if err != nil {
		return nil, err
	}
	entry := topo.NewAddr(tablet.Uid, host)
	entry.NamedPortMap["_vtocc"] = port
	if tablet.SecureAddr != "" {
		host, port, err = netutil.SplitHostPort(tablet.SecureAddr)
		if err != nil {
			return nil, err
		}
		entry.NamedPortMap["_vts"] = port
	}
	host, port, err = netutil.SplitHostPort(tablet.MysqlAddr)
	if err != nil {
		return nil, err
	}
	entry.NamedPortMap["_mysql"] = port
	return entry, nil
}