Skip to content

Commit

Permalink
feature #270: updated the DefaultEventStore initializer to use the gr…
Browse files Browse the repository at this point in the history
…om connection directly from the container instead of copying it into a variable
  • Loading branch information
IshikaGopie committed Jul 24, 2023
1 parent 603ee0f commit 5b6d5da
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions controllers/rest/global_initializers.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,10 @@ func DefaultProjection(ctxt context.Context, tapi Container, swagger *openapi3.S
func DefaultEventStore(ctxt context.Context, tapi Container, swagger *openapi3.Swagger) (context.Context, error) {
api := tapi.(*RESTAPI)
var err error
var gormDB *gorm.DB
gormDB = api.gormConnection
//if there is a projection then add the event handler as a subscriber to the event store
if gormDB != nil {
if api.gormConnection != nil {
var defaultEventStore model.EventRepository
defaultEventStore, err = model.NewBasicEventRepository(gormDB, api.EchoInstance().Logger, false, "", "")
defaultEventStore, err = model.NewBasicEventRepository(api.gormConnection, api.EchoInstance().Logger, false, "", "")
err = defaultEventStore.Migrate(ctxt)
api.RegisterEventStore("Default", defaultEventStore)
}
Expand Down

0 comments on commit 5b6d5da

Please sign in to comment.