Service Logic #92
Unanswered
jakobzudrell
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey there!
Trying my luck even though there has been no activity here for quite some time...
I've been playing around with go and the WTF application for some time now and one thing I haven't really been able to wrap my head around is where to implement "generic" service logic.
Let's look at an
AuthService:I picked this up in another discussion here. The
AuthServiceis a superset of theAuthRepository, latter only implementing CRUD operations whilst theAuthServicesupports some more generic stuff such as generating a token or validating a session - let's keep this design in mind for later...Moving on, the application supports multiple database backends which are abstracted by a
Driverinterface:Each backend implementing the database driver, will have to support my domain model repositories.
Having the Service and Repository separated, I can reduce the codebase in the DB implementations to really only the minimal CRUD operations. But now I don't know where the rest of the
AuthServiceshould be implemented...In my imagination, I'd have a small
smallauth package, that operates independent of anyhttporsqlpackage and provides theAuthService.So basically like this:
maincreates a DB backend which providesNewAuthRepositorymaincreates an auth service usingNewAuthServicefrom theauthpackagemainpasses theAuthServicetohttpwhich can then run "generic" methods, such asGenerateSessionToken()and/or run CRUD operations against theAuthRepository...Any opinions on this?
Beta Was this translation helpful? Give feedback.
All reactions