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() }
Debug: false, LogFile: "", Trace: false, 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) })
var _ = Describe("Agentmanager", func() { var persister brokerapi.Persister var am *dockerapi.AgentManager var dockerServices []brokerapi.Service var cm dockerapi.BrokerConfiguration var err error JustBeforeEach(func() { persister = testnet.NewPersister() persister.Connect() cm = testnet.BrokerConfiguration() dispatcher := testnet.SimpleDispatcher() dockerServices = testnet.NewDockerServices() am, err = dockerapi.NewAgentManager(testnet.BrokerConfiguration(), dispatcher) Expect(err).ShouldNot(HaveOccurred()) }) Describe("brokertest test simpledispatcher", func() { BeforeEach(func() { testnet.SetupSQL(persister) }) AfterEach(func() { testnet.CleanupSQL(persister) }) It("able to receive a ping", func() { sa := brokerapi.ServiceAgent{ ServiceHost: "myFakeHost",