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


Golang AgentServiceRegistration.Checks方法代码示例

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


在下文中一共展示了AgentServiceRegistration.Checks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Register

func (r *ConsulAdapter) Register(service *bridge.Service) error {
	registration := new(consulapi.AgentServiceRegistration)
	registration.ID = service.ID
	registration.Name = service.Name
	registration.Port = service.Port
	registration.Tags = service.Tags
	registration.Address = service.IP
	registration.Checks = r.buildChecks(service)
	return r.client.Agent().ServiceRegister(registration)
}
开发者ID:Marmelatze,项目名称:registrator,代码行数:10,代码来源:consul.go

示例2:

	})

	JustBeforeEach(func() {
		registrationRunner = locket.NewRegistrationRunner(logger, registration, client, 5*time.Second, clock)
	})

	Context("when the service is invalid", func() {
		JustBeforeEach(func() {
			registrationProcess = ifrit.Background(registrationRunner)
		})

		Context("when the service has a value in the Checks list", func() {
			BeforeEach(func() {
				registration.Checks = []*api.AgentServiceCheck{
					&api.AgentServiceCheck{
						TTL: "1m",
					},
				}
			})

			It("returns a validation error", func() {
				Eventually(registrationProcess.Wait()).Should(Receive(MatchError("Support for multiple service checks not implemented")))
			})

			It("does not become ready", func() {
				Consistently(registrationProcess.Ready()).Should(Not(BeClosed()))
			})

			It("does not try to register the service", func() {
				Consistently(agent.ServiceRegisterCallCount).Should(Equal(0))
			})
开发者ID:cloudfoundry,项目名称:locket,代码行数:31,代码来源:registration_runner_test.go


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