Example #1
0
func main() {
	/* Usage: broker [ -config file ] */

	var configFile string

	flag.StringVar(&configFile, "config", "broker.config",
		"Location of configuration file")

	flag.Parse()

	log.Println("ConfigFile:", configFile)
	config, err := dockerapi.NewConfiguration(configFile)
	if err != nil {
		log.Println("Failed to create configuration", err)
		os.Exit(1)
	}

	var dispatcher brokerapi.DispatcherInterface
	switch config.Dispatcher {
	case "SimpleDispatcher":
		dispatcher = dockerapi.NewSimpleDispatcher(*config)
	default:
		dispatcher = dockerapi.NewSimpleDispatcher(*config)
	}
	agentmanager, err := dockerapi.NewAgentManager(*config, dispatcher)
	broker := brokerapi.New(config.GetOpts(), agentmanager)
	broker.Start()
}
Example #2
0
			PidFile:  "",
		}

		config := testnet.BrokerConfiguration()

		serviceagent = testnet.NewServiceAgent()
		persister = config.Persister
		persister.Connect()

		dockerServices = testnet.NewDockerServices()

		dispatcher = testnet.SimpleDispatcher()
		am, err = dockerapi.NewAgentManager(config, dispatcher)
		Expect(err).ShouldNot(HaveOccurred())

		broker := brokerapi.New(opts, am)
		go broker.Start()
		time.Sleep(4 * 1e9)
	})

	Describe("brokertest test broker interface", func() {
		BeforeEach(func() {
			testnet.SetupSQL(persister)
		})
		AfterEach(func() {
			testnet.CleanupSQL(persister)
		})

		It("should publish catalog", func() {
			resp, respCode, err := SendHTTP("GET", BaseURL(opts)+"/v2/catalog", nil)
			Expect(err).To(BeNil())