func main() { // Create the event bus that distributes events. eventBus := eventhorizon.NewInternalEventBus() commandBus := eventhorizon.NewInternalCommandBus() newEventStore := func() (eventhorizon.EventStore, error) { return eventhorizon.NewMemoryEventStore(eventBus), nil } newReadRepository := func(app string) (eventhorizon.ReadRepository, error) { return eventhorizon.NewMemoryReadRepository(), nil } common.Run(eventBus, commandBus, newEventStore, newReadRepository) }
func main() { eventBus := eventhorizon.NewInternalEventBus() commandBus := eventhorizon.NewInternalCommandBus() addr := "localhost" db := "demo" newEventStore := func() (eventhorizon.EventStore, error) { return eventhorizon.NewMongoEventStore(eventBus, addr, db) } newReadRepository := func(name string) (eventhorizon.ReadRepository, error) { return eventhorizon.NewMongoReadRepository(addr, db, name) } common.Run(eventBus, commandBus, newEventStore, newReadRepository) }
func main() { lager.SetLevels(lager.LevelsFromString(os.Getenv("LOG_LEVELS"))) var eventBus eventhorizon.EventBus var commandBus eventhorizon.CommandBus if uri := os.Getenv("RABBITMQ_URI"); uri != "" { remoteEventBus, err := eventhorizon.NewRabbitMQEventBus(uri, "test", "test") if err != nil { log.Fatalln("Unable to create rabbitmq event bus:", err) } defer remoteEventBus.Close() eventBus = remoteEventBus remoteCommandBus, err := eventhorizon.NewRabbitMQCommandBus(uri, "test", "test") if err != nil { log.Fatalln("Unable to create rabbitmq command bus:", err) } defer remoteEventBus.Close() commandBus = remoteCommandBus } else { eventBus = eventhorizon.NewInternalEventBus() commandBus = eventhorizon.NewInternalCommandBus() } conn := os.Getenv("POSTGRES_URL") newEventStore := func() (eventhorizon.EventStore, error) { return eventhorizon.NewPostgresEventStore(eventBus, conn) } newReadRepository := func(name string) (eventhorizon.ReadRepository, error) { return eventhorizon.NewPostgresReadRepository(conn, name) } common.Run(eventBus, commandBus, newEventStore, newReadRepository) }