示例#1
0
文件: main.go 项目: huhoo/vulcand
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()
}
示例#2
0
文件: testapp.go 项目: huhoo/vulcand
// 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),
	}
}