Esempio n. 1
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	// subscription := account.NewEtcdSubscription("/apihub_development", &db.EtcdConfig{Machines: []string{"http://apihub_etcd_1:2379"}})
	subscription := account.NewEtcdSubscription("/apihub_development", &db.EtcdConfig{Machines: []string{"http://127.0.0.1:2379"}})
	// api := api.NewApi(mongore.New(mongore.Config{
	// Host: "apihub_mongo_1:27017",
	// Host:         "127.0.0.1:27017",
	// DatabaseName: "apihub_account_test",
	// }), subscription)
	api := api.NewApi(mem.New(), subscription)

	api.AddHook(account.Hook{
		Name:   "apihub-service-added-slack",
		Team:   account.ALL_TEAMS,
		Events: []string{"service.create"},
		Config: account.HookConfig{Address: "https://hooks.slack.com/services/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"},
		// Config: account.HookConfig{Address: "http://localhost:9999"},
		Text: `{"username": "******", "channel": "#general",
		"icon_emoji": ":ghost:",
		"text": "A new service has been added with the following subdomain: {{.Service.Subdomain}}."}`,
	})

	api.AddHook(account.Hook{
		Name:   "apihub-service-deleted-slack",
		Team:   account.ALL_TEAMS,
		Events: []string{"service.delete"},
		Config: account.HookConfig{Address: "https://hooks.slack.com/services/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"},
		Text: `{"username": "******", "channel": "#general",
		"icon_emoji": ":ghost:",
		"text": "Service -> {{.Service.Subdomain}} <- has been removed ."}`,
	})

	api.ListenEvents()
	api.Run()
}
Esempio n. 2
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	settings := &gateway.Settings{
		Host: "apimanager.org",
		Port: ":8001",
	}

	one := &account.Service{Endpoint: "http://45.55.32.232:8000", Subdomain: "api", Timeout: 3}
	hw := &account.Service{Endpoint: "http://gohttphelloworld.appspot.com", Subdomain: "helloworld", Timeout: 2}
	services := []*account.Service{one, hw}

	pubsub := account.NewEtcdSubscription("/apihub_development", &db.EtcdConfig{Machines: []string{"http://apihub_etcd_1:2379"}})
	gw := gateway.New(settings, pubsub)
	gw.LoadServices(services)
	gw.RefreshServices()
	gw.Run()
}
Esempio n. 3
0
func (s *S) SetUpSuite(c *C) {
	Logger.Disable()
	// FIXME: add memory
	s.pubsub = account.NewEtcdSubscription("/api_test", &db.EtcdConfig{Machines: []string{"http://localhost:2379"}})
}