katzien/go-structure-examples

[Question] How do you deal with a large storage?

feketegy opened this issue · 0 comments

If you have a large domain with a lots of services using the storage, each defining it's own repository interface, then putting those implementations in a single folder under storage/

I find this pattern gets out of hand really quickly, it's fine for smaller examples like the beer review in this repo, but for large APIs where the storage needs to implement a couple of dozen or hundred repository functions is not really usable.

How would you organise the storage folder to break it down more?

I thought of moving the repository implementations in the domain logic, but that would circumvent this architectural pattern; and by further breaking down everything into sub-folders inside storage/ would circumvent Go's package layout.

The only, somewhat, manageable pattern I found is to create files under storage/ by the entities it represents, like storage/job.go, storage/ticket.go, storage/beer.go and write the repository implementations in these files.

Any other ideas?