// NewTestApp creates a new app should be used in unit tests. func NewTestApp() *TestApp { router := mux.NewRouter() registry := ®istry.NopRegistry{} config := scroll.AppConfig{ Name: "test", Router: router, Registry: registry} return &TestApp{ RestHelper{}, scroll.NewAppWithConfig(config), httptest.NewServer(router), } }
// 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 := ®istry.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), } }