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


Golang Controller.WriteServiceDefinitions方法代码示例

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


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

示例1: start

func start(flagSet *flag.FlagSet, path string, controller confab.Controller, agentClient *confab.AgentClient) {
	timeout := confab.NewTimeout(time.After(time.Duration(controller.Config.Confab.TimeoutInSeconds) * time.Second))

	_, err := os.Stat(controller.Config.Path.ConsulConfigDir)
	if err != nil {
		printUsageAndExit(fmt.Sprintf("\"consul_config_dir\" %q could not be found",
			controller.Config.Path.ConsulConfigDir), flagSet)
	}

	if len(agentClient.ExpectedMembers) == 0 {
		printUsageAndExit("at least one \"expected-member\" must be provided", flagSet)
	}

	err = controller.WriteServiceDefinitions()
	if err != nil {
		stderr.Printf("error writing service definitions: %s", err)
		os.Exit(1)
	}

	err = controller.BootAgent(timeout)
	if err != nil {
		stderr.Printf("error booting consul agent: %s", err)

		// DO NOT call StopAgent:
		//   - the agent may aleady be running
		//   - the pidfile may contain the PID of another running process
		os.Exit(1)
	}

	if controller.Config.Consul.Agent.Server {
		configureServer(controller, agentClient, timeout)
	} else {
		configureClient(controller)
	}
}
开发者ID:liuyuns,项目名称:consul-release,代码行数:35,代码来源:main.go

示例2: start

func start(flagSet *flag.FlagSet, path string, controller confab.Controller, agentClient *agent.Client) {
	timeout := confab.NewTimeout(time.After(time.Duration(controller.Config.Confab.TimeoutInSeconds) * time.Second))

	_, err := os.Stat(controller.Config.Path.ConsulConfigDir)
	if err != nil {
		printUsageAndExit(fmt.Sprintf("\"consul_config_dir\" %q could not be found",
			controller.Config.Path.ConsulConfigDir), flagSet)
	}

	if len(agentClient.ExpectedMembers) == 0 {
		printUsageAndExit("at least one \"expected-member\" must be provided", flagSet)
	}

	err = controller.WriteConsulConfig()
	if err != nil {
		stderr.Printf("error writing consul config file: %s", err)
		os.Exit(1)
	}

	err = controller.WriteServiceDefinitions()
	if err != nil {
		stderr.Printf("error writing service definitions: %s", err)
		os.Exit(1)
	}

	err = controller.BootAgent(timeout)
	if err != nil {
		stderr.Printf("error booting consul agent: %s", err)
		exit(controller, 1)
	}

	if controller.Config.Consul.Agent.Mode == "server" {
		configureServer(controller, agentClient, timeout)
	} else {
		configureClient(controller)
	}
}
开发者ID:tkysk,项目名称:consul-release,代码行数:37,代码来源:main.go

示例3:

			EncryptKeys:    []string{"key 1", "key 2", "key 3"},
			Logger:         logger,
			ConfigDir:      "/tmp/config",
			ServiceDefiner: serviceDefiner,
			Config:         confabConfig,
		}
	})

	Describe("WriteServiceDefinitions", func() {
		It("delegates to the service definer", func() {
			definitions := []confab.ServiceDefinition{{
				Name: "banana",
			}}
			serviceDefiner.GenerateDefinitionsCall.Returns.Definitions = definitions

			Expect(controller.WriteServiceDefinitions()).To(Succeed())
			Expect(serviceDefiner.GenerateDefinitionsCall.Receives.Config).To(Equal(controller.Config))
			Expect(serviceDefiner.WriteDefinitionsCall.Receives.ConfigDir).To(Equal("/tmp/config"))
			Expect(serviceDefiner.WriteDefinitionsCall.Receives.Definitions).To(Equal(definitions))

			Expect(logger.Messages).To(ContainSequence([]fakes.LoggerMessage{
				{
					Action: "controller.write-service-definitions.generate-definitions",
				},
				{
					Action: "controller.write-service-definitions.write",
				},
				{
					Action: "controller.write-service-definitions.success",
				},
			}))
开发者ID:liuyuns,项目名称:consul-release,代码行数:31,代码来源:controller_test.go


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