Skip to content

Commit

Permalink
feat: add GetApplicationRepository method to Container for lazy initi…
Browse files Browse the repository at this point in the history
…alization of ApplicationRepository
  • Loading branch information
sandhilt committed Jan 31, 2025
1 parent 300fc90 commit 0bcdbb8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/convenience/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type Container struct {
AutoCount bool
rawInputRefRepository *repository.RawInputRefRepository
rawOutputRefRepository *repository.RawOutputRefRepository
appRepository *repository.ApplicationRepository
}

func NewContainer(db sqlx.DB, autoCount bool) *Container {
Expand All @@ -36,6 +37,20 @@ func NewContainer(db sqlx.DB, autoCount bool) *Container {
}
}

func (c *Container) GetApplicationRepository() *repository.ApplicationRepository {
if c.appRepository != nil {
return c.appRepository
}
c.appRepository = &repository.ApplicationRepository{
Db: *c.db,
}
err := c.appRepository.CreateTables()
if err != nil {
panic(err)
}
return c.appRepository
}

func (c *Container) GetOutputDecoder() *decoder.OutputDecoder {
if c.outputDecoder != nil {
return c.outputDecoder
Expand Down

0 comments on commit 0bcdbb8

Please sign in to comment.