Example #1
0
func main() {
	name := "loadbalancer"

	registry, err := registry.NewLBRegistry("scrollexamples/lb", 5)
	if err != nil {
		return
	}

	appConfig := scroll.AppConfig{
		Name:             name,
		ListenIP:         host,
		ListenPort:       port,
		Registry:         registry,
		PublicAPIHost:    "public.local",
		ProtectedAPIHost: "private.local",
	}

	handlerSpec := scroll.Spec{
		Scopes:  []scroll.Scope{scroll.ScopePublic, scroll.ScopeProtected},
		Methods: []string{"GET"},
		Paths:   []string{"/"},
		Handler: index,
	}

	fmt.Printf("Starting %s on %s:%d...\n", name, host, port)

	app := scroll.NewAppWithConfig(appConfig)
	app.AddHandler(handlerSpec)
	app.Run()
}
Example #2
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),
	}
}