Пример #1
0
// NewTestApp creates a new app should be used in unit tests.
func NewTestApp() *TestApp {
	router := mux.NewRouter()
	return &TestApp{
		RestHelper{},
		scroll.NewAppWithConfig(scroll.AppConfig{Router: router}),
		httptest.NewServer(router),
	}
}
Пример #2
0
func (s *ApiSuite) SetUpTest(c *C) {
	s.backend = membackend.NewMemBackend(registry.GetRegistry())

	muxRouter := mux.NewRouter()
	hostRouter := hostroute.NewHostRouter()
	proxy, err := vulcan.NewProxy(hostRouter)
	configurator := configure.NewConfigurator(proxy)
	c.Assert(err, IsNil)

	InitProxyController(s.backend, adapter.NewAdapter(proxy), configurator.GetConnWatcher(), muxRouter)
	s.testServer = httptest.NewServer(muxRouter)
	s.client = NewClient(s.testServer.URL, registry.GetRegistry())
}
Пример #3
0
// NewTestApp creates a new app should be used in unit tests.
func NewTestApp() *TestApp {
	router := mux.NewRouter()
	registry := &registry.NopRegistry{}
	config := scroll.AppConfig{
		Name:     "test",
		Router:   router,
		Registry: registry}

	return &TestApp{
		RestHelper{},
		scroll.NewAppWithConfig(config),
		httptest.NewServer(router),
	}
}
Пример #4
0
// Create a new app with the provided configuration.
func NewAppWithConfig(config AppConfig) *App {
	router := config.Router
	if router == nil {
		router = mux.NewRouter()
	}

	interval := config.Interval
	if interval == 0 {
		interval = defaultRegisterInterval
	}

	registration := &registry.AppRegistration{Name: config.Name, Host: config.ListenIP, Port: config.ListenPort}
	heartbeater := registry.NewHeartbeater(registration, config.Registry, interval)

	return &App{
		Config:      config,
		router:      router,
		heartbeater: heartbeater,
		stats:       newAppStats(config.Client),
	}
}
Пример #5
0
func (s *Service) initApi() error {
	s.apiRouter = mux.NewRouter()
	api.InitProxyController(s.backend, adapter.NewAdapter(s.proxy), s.configurator.GetConnWatcher(), s.apiRouter)
	return nil
}