本文整理匯總了Golang中github.com/cloudfoundry-incubator/lattice/ltc/route_helpers.AppRoutes類的典型用法代碼示例。如果您正苦於以下問題:Golang AppRoutes類的具體用法?Golang AppRoutes怎麽用?Golang AppRoutes使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了AppRoutes類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: updateLrpRoutes
func (appRunner *appRunner) updateLrpRoutes(name string, routes RouteOverrides) error {
appRoutes := route_helpers.AppRoutes{}
routeMap := make(map[uint16][]string)
for _, override := range routes {
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,
})
}
err := appRunner.receptorClient.UpdateDesiredLRP(
name,
receptor.DesiredLRPUpdateRequest{
Routes: appRoutes.RoutingInfo(),
},
)
return err
}
示例2:
import (
"encoding/json"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/cloudfoundry-incubator/lattice/ltc/route_helpers"
. "github.com/cloudfoundry-incubator/lattice/ltc/test_helpers/matchers"
"github.com/cloudfoundry-incubator/receptor"
)
var _ = Describe("RoutingInfoHelpers", func() {
var (
appRoute1 route_helpers.AppRoute
appRoute2 route_helpers.AppRoute
appRoute3 route_helpers.AppRoute
appRoutes route_helpers.AppRoutes
)
BeforeEach(func() {
appRoute1 = route_helpers.AppRoute{
Hostnames: []string{"foo1.example.com", "bar1.examaple.com"},
Port: 11111,
}
appRoute2 = route_helpers.AppRoute{
Hostnames: []string{"foo2.example.com", "bar2.examaple.com"},
Port: 22222,
}
appRoute3 = route_helpers.AppRoute{
Hostnames: []string{"foo3.example.com", "bar3.examaple.com"},
示例3: desireLrp
func (appRunner *appRunner) desireLrp(params CreateAppParams) error {
primaryPort := uint16(0)
if params.Monitor.Port != 0 {
primaryPort = params.Monitor.Port
} else if len(params.ExposedPorts) > 0 {
primaryPort = params.ExposedPorts[0]
}
envVars := buildEnvironmentVariables(params.EnvironmentVariables)
envVars = append(envVars, receptor.EnvironmentVariable{Name: "PORT", Value: fmt.Sprintf("%d", primaryPort)})
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)
}
req := receptor.DesiredLRPCreateRequest{
ProcessGuid: params.Name,
Domain: lrpDomain,
RootFS: params.RootFS,
Instances: params.Instances,
Routes: appRoutes.RoutingInfo(),
CPUWeight: params.CPUWeight,
MemoryMB: params.MemoryMB,
DiskMB: params.DiskMB,
Privileged: params.Privileged,
Ports: params.ExposedPorts,
LogGuid: params.Name,
LogSource: "APP",
MetricsGuid: params.Name,
EnvironmentVariables: envVars,
Setup: params.Setup,
Action: &models.RunAction{
Path: params.StartCommand,
Args: params.AppArgs,
Dir: params.WorkingDir,
},
}
var healthCheckArgs []string
if params.Monitor.Timeout != 0 {
healthCheckArgs = append(healthCheckArgs, "-timeout", fmt.Sprint(params.Monitor.Timeout))
}
switch params.Monitor.Method {
case PortMonitor:
req.Monitor = &models.RunAction{
Path: "/tmp/healthcheck",
Args: append(healthCheckArgs, "-port", fmt.Sprint(params.Monitor.Port)),
LogSource: "HEALTH",
}
case URLMonitor:
req.Monitor = &models.RunAction{
Path: "/tmp/healthcheck",
Args: append(healthCheckArgs, "-port", fmt.Sprint(params.Monitor.Port), "-uri", params.Monitor.URI),
LogSource: "HEALTH",
}
}
return appRunner.receptorClient.CreateDesiredLRP(req)
}
示例4:
import (
"encoding/json"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/cloudfoundry-incubator/lattice/ltc/route_helpers"
"github.com/cloudfoundry-incubator/receptor"
)
var _ = Describe("RoutingInfoHelpers", func() {
var (
route1 route_helpers.AppRoute
route2 route_helpers.AppRoute
route3 route_helpers.AppRoute
routes route_helpers.AppRoutes
)
BeforeEach(func() {
route1 = route_helpers.AppRoute{
Hostnames: []string{"foo1.example.com", "bar1.examaple.com"},
Port: 11111,
}
route2 = route_helpers.AppRoute{
Hostnames: []string{"foo2.example.com", "bar2.examaple.com"},
Port: 22222,
}
route3 = route_helpers.AppRoute{
Hostnames: []string{"foo3.example.com", "bar3.examaple.com"},