本文整理汇总了Golang中github.com/youtube/vitess/go/netutil.FullyQualifiedHostnameOrPanic函数的典型用法代码示例。如果您正苦于以下问题:Golang FullyQualifiedHostnameOrPanic函数的具体用法?Golang FullyQualifiedHostnameOrPanic怎么用?Golang FullyQualifiedHostnameOrPanic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FullyQualifiedHostnameOrPanic函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
defer exit.Recover()
defer logutil.Flush()
zknsDomain := flag.String("zkns-domain", "", "The naming hierarchy portion to serve")
zknsRoot := flag.String("zkns-root", "", "The root path from which to resolve")
bindAddr := flag.String("bind-addr", ":31981", "Bind the debug http server")
flag.Parse()
if *bindAddr != "" {
go func() {
err := http.ListenAndServe(*bindAddr, nil)
if err != nil {
log.Errorf("ListenAndServe: %s", err)
exit.Return(1)
}
}()
}
zconn := zk.NewMetaConn()
fqdn := netutil.FullyQualifiedHostnameOrPanic()
zr1 := newZknsResolver(zconn, fqdn, *zknsDomain, *zknsRoot)
pd := &pdns{zr1}
pd.Serve(os.Stdin, os.Stdout)
os.Stdout.Close()
}
示例2: MakeZkConfigFromString
/*
Create a config for this instance.
<server_id>@<hostname>:<leader_port>:<election_port>:<client_port>
If server_id > 1000, then we assume this is a global quorum.
server_id's must be 1-255, global id's are 1001-1255 mod 1000.
*/
func MakeZkConfigFromString(cmdLine string, myId uint32) *ZkConfig {
zkConfig := NewZkConfig()
for _, zki := range strings.Split(cmdLine, ",") {
zkiParts := strings.SplitN(zki, "@", 2)
if len(zkiParts) != 2 {
panic("bad command line format for zk config")
}
zkId := zkiParts[0]
zkAddrParts := strings.Split(zkiParts[1], ":")
serverId, _ := strconv.ParseUint(zkId, 10, 0)
if serverId > 1000 {
serverId = serverId % 1000
zkConfig.Global = true
}
myId = myId % 1000
zkServer := zkServerAddr{ServerId: uint32(serverId), ClientPort: 2181,
LeaderPort: 2888, ElectionPort: 3888}
switch len(zkAddrParts) {
case 4:
zkServer.ClientPort, _ = strconv.Atoi(zkAddrParts[3])
fallthrough
case 3:
zkServer.ElectionPort, _ = strconv.Atoi(zkAddrParts[2])
fallthrough
case 2:
zkServer.LeaderPort, _ = strconv.Atoi(zkAddrParts[1])
fallthrough
case 1:
zkServer.Hostname = zkAddrParts[0]
// if !strings.Contains(zkServer.Hostname, ".") {
// panic(fmt.Errorf("expected fully qualified hostname: %v", zkServer.Hostname))
// }
default:
panic(fmt.Errorf("bad command line format for zk config"))
}
zkConfig.Servers = append(zkConfig.Servers, zkServer)
}
hostname := netutil.FullyQualifiedHostnameOrPanic()
log.Infof("Fully qualified machine hostname was detected as: %v", hostname)
for _, zkServer := range zkConfig.Servers {
if (myId > 0 && myId == zkServer.ServerId) || (myId == 0 && zkServer.Hostname == hostname) {
zkConfig.ServerId = zkServer.ServerId
zkConfig.ClientPort = zkServer.ClientPort
break
}
}
if zkConfig.ServerId == 0 {
panic(fmt.Errorf("no zk server found for host %v in config %v", hostname, cmdLine))
}
return zkConfig
}
示例3: Addr
// Addr returns the fully qualified host name + port for this instance.
func (mysqld *Mysqld) Addr() string {
hostname := netutil.FullyQualifiedHostnameOrPanic()
return netutil.JoinHostPort(hostname, int32(mysqld.config.MysqlPort))
}
示例4: Addr
func (mysqld *Mysqld) Addr() string {
hostname := netutil.FullyQualifiedHostnameOrPanic()
return fmt.Sprintf("%v:%v", hostname, mysqld.config.MysqlPort)
}
示例5:
"Entries": [
{
"host": "test1"
}
]}`
fakeA = `{
"Entries": [
{
"host": "test1",
"ipv4": "0.0.0.1"
}
]}`
)
var fqdn = netutil.FullyQualifiedHostnameOrPanic()
var zconn = &TestZkConn{map[string]string{
"/zk/test/zkns/srv": fakeSRV,
"/zk/test/zkns/cname": fakeCNAME,
"/zk/test/zkns/a": fakeA,
}}
var queries = []string{
"Q\t_http.srv.zkns.test.zk\tIN\tANY\t-1\t1.1.1.1\t1.1.1.2",
"Q\ta.zkns.test.zk\tIN\tANY\t-1\t1.1.1.1\t1.1.1.2",
"Q\tcname.zkns.test.zk\tIN\tANY\t-1\t1.1.1.1\t1.1.1.2",
"Q\tempty.zkns.test.zk\tIN\tANY\t-1\t1.1.1.1\t1.1.1.2",
"Q\bad.domain\tIN\tANY\t-1\t1.1.1.1\t1.1.1.2",
}