Skip to content

Constructing services, dependencies during server creation #17

Answered by MarioCarrion
Kamariw95 asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @Kamariw95

The initialization process would be similar; if the concrete repositories use the same underlying datastore (literally the same host) then they would be initialized with that variable, for example (assuming postgresql-related types):

user := postgresl.NewUser(conf.DB)
subtask := postgresl.NewSubtask(conf.DB)

Those instances then would be sent to the corresponding service types to initialize the corresponding type, for example:

svcUser := service.NewUser(user)
svcSubtask := service.NewSubtask(subtask) 

The "tricky" part of all of this is to properly organize the repositories in a way they make sense for the data they are using behind the scenes, for example, let's assume t…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Kamariw95
Comment options

Answer selected by MarioCarrion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants