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


Golang Routes.TcpRoutes方法代碼示例

本文整理匯總了Golang中github.com/cloudfoundry-incubator/lattice/ltc/route_helpers.Routes.TcpRoutes方法的典型用法代碼示例。如果您正苦於以下問題:Golang Routes.TcpRoutes方法的具體用法?Golang Routes.TcpRoutes怎麽用?Golang Routes.TcpRoutes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cloudfoundry-incubator/lattice/ltc/route_helpers.Routes的用法示例。


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

示例1: buildRoutes

func (appRunner *appRunner) buildRoutes(params CreateAppParams, primaryPort uint16) route_helpers.Routes {
	var routes route_helpers.Routes

	var appRoutes route_helpers.AppRoutes
	if params.NoRoutes {
		appRoutes = route_helpers.AppRoutes{}
	} else if len(params.RouteOverrides) > 0 {
		routeMap := make(map[uint16][]string)
		for _, override := range params.RouteOverrides {
			routeMap[override.Port] = append(routeMap[override.Port], fmt.Sprintf("%s.%s", override.HostnamePrefix, appRunner.systemDomain))
		}
		for port, hostnames := range routeMap {
			appRoutes = append(appRoutes, route_helpers.AppRoute{
				Hostnames: hostnames,
				Port:      port,
			})
		}
	} else {
		appRoutes = appRunner.buildDefaultRoutingInfo(params.Name, params.ExposedPorts, primaryPort)
	}

	var tcpRoutes route_helpers.TcpRoutes
	if !params.NoRoutes && len(params.TcpRoutes) > 0 {
		for _, tcpRoute := range params.TcpRoutes {
			tcpRoutes = append(tcpRoutes, route_helpers.TcpRoute{
				ExternalPort: tcpRoute.ExternalPort,
				Port:         tcpRoute.Port,
			})
		}
		routes.TcpRoutes = tcpRoutes
	}

	routes.AppRoutes = appRoutes
	return routes
}
開發者ID:edwardt,項目名稱:lattice,代碼行數:35,代碼來源:app_runner.go

示例2: buildRoutes

func (appRunner *appRunner) buildRoutes(noRoutes bool, routeOverrides RouteOverrides, tcpRoutes TcpRoutes) route_helpers.Routes {
	var routes route_helpers.Routes

	var appRoutes route_helpers.AppRoutes
	if noRoutes {
		appRoutes = route_helpers.AppRoutes{}
	} else if len(routeOverrides) > 0 {
		routeMap := make(map[uint16][]string)
		for _, override := range routeOverrides {
			routeMap[override.Port] = append(routeMap[override.Port], fmt.Sprintf("%s.%s", override.HostnamePrefix, appRunner.systemDomain))
		}
		for port, hostnames := range routeMap {
			appRoutes = append(appRoutes, route_helpers.AppRoute{
				Hostnames: hostnames,
				Port:      port,
			})
		}
	}

	var appTcpRoutes route_helpers.TcpRoutes
	if !noRoutes && len(tcpRoutes) > 0 {
		for _, tcpRoute := range tcpRoutes {
			appTcpRoutes = append(appTcpRoutes, route_helpers.TcpRoute{
				ExternalPort: tcpRoute.ExternalPort,
				Port:         tcpRoute.Port,
			})
		}
		routes.TcpRoutes = appTcpRoutes
	}

	routes.AppRoutes = appRoutes
	return routes
}
開發者ID:hpcloud,項目名稱:lattice,代碼行數:33,代碼來源:app_runner.go


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