当前位置: 首页>>代码示例>>Golang>>正文


Golang AppRoutes.RoutingInfo方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry-incubator/lattice/ltc/route_helpers.AppRoutes.RoutingInfo方法的典型用法代码示例。如果您正苦于以下问题:Golang AppRoutes.RoutingInfo方法的具体用法?Golang AppRoutes.RoutingInfo怎么用?Golang AppRoutes.RoutingInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry-incubator/lattice/ltc/route_helpers.AppRoutes的用法示例。


在下文中一共展示了AppRoutes.RoutingInfo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
开发者ID:edwardt,项目名称:lattice,代码行数:23,代码来源:app_runner.go

示例2: 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)
}
开发者ID:rajkumargithub,项目名称:lattice,代码行数:73,代码来源:app_runner.go

示例3:

			Port:      22222,
		}
		route3 = route_helpers.AppRoute{
			Hostnames: []string{"foo3.example.com", "bar3.examaple.com"},
			Port:      33333,
		}

		routes = route_helpers.AppRoutes{route1, route2, route3}
	})

	Describe("AppRoutes", func() {
		Describe("RoutingInfo", func() {
			var routingInfo receptor.RoutingInfo

			JustBeforeEach(func() {
				routingInfo = routes.RoutingInfo()
			})

			It("wraps the serialized routes with the correct key", func() {
				expectedBytes, err := json.Marshal(routes)
				Expect(err).ToNot(HaveOccurred())

				payload, err := routingInfo[route_helpers.AppRouter].MarshalJSON()
				Expect(err).ToNot(HaveOccurred())

				Expect(payload).To(MatchJSON(expectedBytes))
			})

			Context("when AppRoutes is empty", func() {
				BeforeEach(func() {
					routes = route_helpers.AppRoutes{}
开发者ID:rajkumargithub,项目名称:lattice,代码行数:31,代码来源:route_helpers_test.go

示例4:

			Port:      22222,
		}
		appRoute3 = route_helpers.AppRoute{
			Hostnames: []string{"foo3.example.com", "bar3.examaple.com"},
			Port:      33333,
		}

		appRoutes = route_helpers.AppRoutes{appRoute1, appRoute2, appRoute3}
	})

	Describe("AppRoutes", func() {
		Describe("RoutingInfo", func() {
			var routingInfo receptor.RoutingInfo

			JustBeforeEach(func() {
				routingInfo = appRoutes.RoutingInfo()
			})

			It("maps the serialized routes to the correct key", func() {
				expectedBytes := []byte(`[{"hostnames":["foo1.example.com","bar1.examaple.com"],"port":11111},{"hostnames":["foo2.example.com","bar2.examaple.com"],"port":22222},{"hostnames":["foo3.example.com","bar3.examaple.com"],"port":33333}]`)
				Expect(appRoutes.RoutingInfo()["cf-router"].MarshalJSON()).To(MatchJSON(expectedBytes))
			})

			Context("when AppRoutes is empty", func() {
				BeforeEach(func() {
					appRoutes = route_helpers.AppRoutes{}
				})

				It("marshals an empty list", func() {
					payload, err := routingInfo["cf-router"].MarshalJSON()
					Expect(err).NotTo(HaveOccurred())
开发者ID:davidwadden,项目名称:lattice-release,代码行数:31,代码来源:route_helpers_test.go

示例5:

		}
		appRoute3 = route_helpers.AppRoute{
			Hostnames: []string{"foo3.example.com", "bar3.examaple.com"},
			Port:      33333,
		}

		appRoutes = route_helpers.AppRoutes{appRoute1, appRoute2, appRoute3}

	})

	Describe("AppRoutes", func() {
		Describe("RoutingInfo", func() {
			var routingInfo receptor.RoutingInfo

			JustBeforeEach(func() {
				routingInfo = appRoutes.RoutingInfo()
			})

			It("wraps the serialized routes with the correct key", func() {
				expectedBytes, err := json.Marshal(appRoutes)
				Expect(err).NotTo(HaveOccurred())

				payload, err := routingInfo[route_helpers.AppRouter].MarshalJSON()
				Expect(err).NotTo(HaveOccurred())

				Expect(payload).To(MatchJSON(expectedBytes))
			})

			Context("when AppRoutes is empty", func() {
				BeforeEach(func() {
					appRoutes = route_helpers.AppRoutes{}
开发者ID:hpcloud,项目名称:lattice,代码行数:31,代码来源:route_helpers_test.go


注:本文中的github.com/cloudfoundry-incubator/lattice/ltc/route_helpers.AppRoutes.RoutingInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。