示例#1
0
func main() {

	log.Println("Setting GOMAXPROCS = ", runtime.NumCPU())
	runtime.GOMAXPROCS(runtime.NumCPU())

	cmdStore := memory.NewCommandStore(10000) // config: max queued commands is 10k
	eventBus := memory.NewEventBus(false)     // config: false means not async

	cmdServiceOptions := services.CommandServiceOptions{
		TransactionsPerSecond: 100,
		BackOffDuration:       1 * time.Second,
	}
	cmdService := services.NewCommandService(cmdServiceOptions, cmdStore)

	framework := sourcing.NewFramework(memory.NewEventStore())

	refSvc := domainServices.NewDummyMeetingService()
	model.BindEvents(framework, refSvc)

	commands.BindHandlers(framework, cmdService, eventBus)

	api.Register(cmdStore)

	go cmdService.Start()
	defer cmdService.Stop()

	initSwagger()

	err := http.ListenAndServe(":8080", nil)
	if err != nil {
		log.Fatal(err)
	}
}
func (t *DomainTests) SetUpTest(c *check.C) {
	t.framework = sourcing.NewFramework(memory.NewEventStore())
	t.user = &MeetingUser{
		Type:       UserType_Google,
		ExternalId: "me user",
	}

	BindEvents(t.framework, NewDummyMeetingService())
}