Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // We would make a seaprate {service}/data package. The reason to separate out the data module is to utilize
- // private methods to not expose lower-level resources
- // We would no longer need the big global Databinder and instead replace it with a smaller Binder for each resource
- // The benifit of switching off of the interface is we can then leverage private attributes like the clients
- // The Binders can expose sqlx components like tx in private functions
- // The binder methods would be raw management of the resources with no side-effects (i.e. creating a guest
- // would not create a guest token)
- type GuestBinder struct {
- Get func() error
- Update func() error
- Insert func() error
- db *DB
- identity *identity.Client
- }
- func NewGuestBinder(identity identity.Client) *GuestBinder {}
- func NewGuestBinderMock() *GuestBinder {}
- type TokenBinder struct {
- Get func() error
- Update func() error
- Insert func() error
- updateBatch func(tx *sqlx.Tx) error
- db *DB
- }
- func NewTokenBinder(identity identity.Client) *GuestBinder {}
- func NewTokenBinderMock() *GuestBinder {}
- // The you would dependency inject the binders into the processor.
- // These can act as processors which can coordinate and utilize private methods accross the different binders
- // i.e. CreateGuest would create a guest, token, and ledger entry etc...
- type GuestProcessor struct {
- Create func() error {}
- ActivateGuest func() error {}
- guest *GuestBinder
- token *TokenBinder
- identity *identity.Client
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement