func (s *ApiSuite) SetUpTest(c *C) { newProxy := func(id int) (proxy.Proxy, error) { return proxy.New(id, stapler.New(), proxy.Options{}) } s.ng = memng.New(registry.GetRegistry()) sv := supervisor.New(newProxy, s.ng, make(chan error), supervisor.Options{}) app := scroll.NewApp() InitProxyController(s.ng, sv, app) s.testServer = httptest.NewServer(app.GetHandler()) s.client = NewClient(s.testServer.URL, registry.GetRegistry()) }
func main() { cmd := command.NewCommand(registry.GetRegistry()) err := cmd.Run(os.Args) if err != nil { cmd.PrintError(err) } }
func main() { cmd := command.NewCommand(registry.GetRegistry()) err := cmd.Run(os.Args) if err != nil { log.Errorf("error: %s\n", err) } }
func (s *MemSuite) SetUpTest(c *C) { engine := New(registry.GetRegistry()) s.suite.ChangesC = make(chan interface{}) s.stopC = make(chan bool) go engine.Subscribe(s.suite.ChangesC, 0, s.stopC) s.suite.Engine = engine }
func (s *CmdSuite) run(params ...string) string { args := []string{"vctl"} args = append(args, params...) args = append(args, fmt.Sprintf("--vulcan=%s", s.testServer.URL)) s.out = &bytes.Buffer{} s.cmd = &Command{registry: registry.GetRegistry(), out: s.out, vulcanUrl: s.testServer.URL} s.cmd.Run(args) return strings.Replace(s.out.String(), "\n", " ", -1) }
func (s *CmdSuite) SetUpTest(c *C) { s.ng = memng.New(registry.GetRegistry()) newProxy := func(id int) (proxy.Proxy, error) { return proxy.New(id, stapler.New(), proxy.Options{}) } sv := supervisor.New(newProxy, s.ng, make(chan error), supervisor.Options{}) sv.Start() s.sv = sv app := scroll.NewApp() api.InitProxyController(s.ng, sv, app) s.testServer = httptest.NewServer(app.GetHandler()) s.out = &bytes.Buffer{} s.cmd = &Command{registry: registry.GetRegistry(), out: s.out, vulcanUrl: s.testServer.URL} }
func main() { runtime.GOMAXPROCS(runtime.NumCPU()) if err := service.Run(registry.GetRegistry()); err != nil { fmt.Printf("Service exited with error: %s\n", err) os.Exit(255) } else { fmt.Println("Service exited gracefully") } }
func main() { log.InitWithConfig(log.Config{Name: "console"}) cmd := command.NewCommand(registry.GetRegistry()) err := cmd.Run(os.Args) if err != nil { log.Errorf("error: %s\n", err) } }
func (s *SupervisorSuite) SetUpTest(c *C) { s.ng = memng.New(registry.GetRegistry()).(*memng.Mem) s.errorC = make(chan error) s.clock = &timetools.FreezedTime{ CurrentTime: time.Date(2012, 3, 4, 5, 6, 7, 0, time.UTC), } s.sv = New(newProxy, s.ng, s.errorC, Options{Clock: s.clock}) }
func NewRegistry( addr, backendID, serverID, ipAddress string, port uint, ttl time.Duration) *Registry { return &Registry{ api.NewClient(addr, registry.GetRegistry()), backendID, serverID, fmt.Sprintf("http://%s:%d", ipAddress, port), ttl, } }
func (s *S) SetUpTest(c *check.C) { var err error s.conn, err = db.Conn() c.Assert(err, check.IsNil) dbtest.ClearAllCollections(s.conn.Collection("router_vulcand_tests").Database) s.engine = memng.New(registry.GetRegistry()) scrollApp := scroll.NewApp() api.InitProxyController(s.engine, &supervisor.Supervisor{}, scrollApp) s.vulcandServer = httptest.NewServer(scrollApp.GetHandler()) config.Set("routers:vulcand:api-url", s.vulcandServer.URL) }
func (s *EtcdSuite) SetUpTest(c *C) { // Initiate a backend with a registry key, err := secret.KeyFromString(s.key) c.Assert(err, IsNil) box, err := secret.NewBox(key) c.Assert(err, IsNil) engine, err := New( s.nodes, s.etcdPrefix, registry.GetRegistry(), Options{ EtcdConsistency: s.consistency, Box: box, }) c.Assert(err, IsNil) s.ng = engine.(*ng) s.client = s.ng.client s.context = context.Background() // Delete all values under the given prefix _, err = s.client.Get(s.context, s.etcdPrefix) if err != nil { // There's no key like this if !notFound(err) { // We haven't expected this error, oops c.Assert(err, IsNil) } } else { _, err = s.ng.client.Delete(s.context, s.etcdPrefix, etcd.WithPrefix()) c.Assert(err, IsNil) } s.changesC = make(chan interface{}) s.stopC = make(chan bool) //find current index, so we only watch from now onwards response, err := s.ng.client.Get(s.ng.context, "/") c.Assert(response, NotNil) c.Assert(err, IsNil) go s.ng.Subscribe(s.changesC, uint64(response.Header.Revision+1), s.stopC) s.suite.ChangesC = s.changesC s.suite.Engine = engine }
func createRouter(routerName, configPrefix string) (router.Router, error) { vURL, err := config.GetString(configPrefix + ":api-url") if err != nil { return nil, err } domain, err := config.GetString(configPrefix + ":domain") if err != nil { return nil, err } client := api.NewClient(vURL, registry.GetRegistry()) vRouter := &vulcandRouter{ client: client, prefix: configPrefix, domain: domain, } return vRouter, nil }
func (s *EtcdSuite) SetUpTest(c *C) { // Initiate a backend with a registry key, err := secret.KeyFromString(s.key) c.Assert(err, IsNil) box, err := secret.NewBox(key) c.Assert(err, IsNil) engine, err := New( s.nodes, s.etcdPrefix, registry.GetRegistry(), Options{ EtcdConsistency: s.consistency, Box: box, }) c.Assert(err, IsNil) s.ng = engine.(*ng) s.client = s.ng.client s.kapi = s.ng.kapi // Delete all values under the given prefix _, err = s.kapi.Get(s.context, s.etcdPrefix, &etcd.GetOptions{Recursive: false, Sort: false}) if err != nil { // There's no key like this if !notFound(err) { // We haven't expected this error, oops c.Assert(err, IsNil) } } else { _, err = s.ng.kapi.Delete(s.context, s.etcdPrefix, &etcd.DeleteOptions{Recursive: true}) c.Assert(err, IsNil) } s.changesC = make(chan interface{}) s.stopC = make(chan bool) go s.ng.Subscribe(s.changesC, s.stopC) s.suite.ChangesC = s.changesC s.suite.Engine = engine }