當前位置: 首頁>>代碼示例>>Golang>>正文


Golang process.Process類代碼示例

本文整理匯總了Golang中github.com/mesos/mesos-go/mesosutil/process.Process的典型用法代碼示例。如果您正苦於以下問題:Golang Process類的具體用法?Golang Process怎麽用?Golang Process使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Process類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ForHostname

// ForHostname creates a new default messenger (HTTP), using UPIDBindingAddress to
// determine the binding-address used for both the UPID.Host and Transport binding address.
func ForHostname(proc *process.Process, hostname string, bindingAddress net.IP, port uint16, publishedAddress net.IP) (Messenger, error) {
	upid := upid.UPID{
		ID:   proc.Label(),
		Port: strconv.Itoa(int(port)),
	}
	host, err := UPIDBindingAddress(hostname, bindingAddress)
	if err != nil {
		return nil, err
	}

	var publishedHost string
	if publishedAddress != nil {
		publishedHost, err = UPIDBindingAddress(hostname, publishedAddress)
		if err != nil {
			return nil, err
		}
	}

	if publishedHost != "" {
		upid.Host = publishedHost
	} else {
		upid.Host = host
	}

	return NewHttpWithBindingAddress(upid, bindingAddress), nil
}
開發者ID:rkazak,項目名稱:swarm,代碼行數:28,代碼來源:messenger.go

示例2: ForHostname

// create a new default messenger (HTTP). If a non-nil, non-wildcard bindingAddress is
// specified then it will be used for both the UPID and Transport binding address. Otherwise
// hostname is resolved to an IP address and the UPID.Host is set to that address and the
// bindingAddress is passed through to the Transport.
func ForHostname(proc *process.Process, hostname string, bindingAddress net.IP, port uint16) (Messenger, error) {
	upid := &upid.UPID{
		ID:   proc.Label(),
		Port: strconv.Itoa(int(port)),
	}
	if bindingAddress != nil && "0.0.0.0" != bindingAddress.String() {
		upid.Host = bindingAddress.String()
	} else {
		ips, err := net.LookupIP(hostname)
		if err != nil {
			return nil, err
		}
		// try to find an ipv4 and use that
		ip := net.IP(nil)
		for _, addr := range ips {
			if ip = addr.To4(); ip != nil {
				break
			}
		}
		if ip == nil {
			// no ipv4? best guess, just take the first addr
			if len(ips) > 0 {
				ip = ips[0]
				log.Warningf("failed to find an IPv4 address for '%v', best guess is '%v'", hostname, ip)
			} else {
				return nil, fmt.Errorf("failed to determine IP address for host '%v'", hostname)
			}
		}
		upid.Host = ip.String()
	}
	return NewHttpWithBindingAddress(upid, bindingAddress), nil
}
開發者ID:nagyistoce,項目名稱:ms-docker-swarm,代碼行數:36,代碼來源:messenger.go

示例3: ForHostname

// ForHostname creates a new default messenger (HTTP), using UPIDBindingAddress to
// determine the binding-address used for both the UPID.Host and Transport binding address.
func ForHostname(proc *process.Process, hostname string, bindingAddress net.IP, port uint16) (Messenger, error) {
	upid := &upid.UPID{
		ID:   proc.Label(),
		Port: strconv.Itoa(int(port)),
	}
	host, err := UPIDBindingAddress(hostname, bindingAddress)
	if err != nil {
		return nil, err
	}
	upid.Host = host
	return NewHttpWithBindingAddress(upid, bindingAddress), nil
}
開發者ID:jjhbeloved,項目名稱:Mesos-Bitcoin-Miner,代碼行數:14,代碼來源:messenger.go


注:本文中的github.com/mesos/mesos-go/mesosutil/process.Process類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。