Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why are service interfaces not defined near the consumer (rest-handler)? #43

Open
wilfreddesert opened this issue Aug 17, 2023 · 2 comments

Comments

@wilfreddesert
Copy link

Hi!
I am referring to the hexagonal architecture example. It's a well-known idiom in Go that a consumer defines the interfaces it needs. In this particular case, why not define the three service interfaces in the http package?

Thanks!

@godwhoa
Copy link

godwhoa commented Aug 18, 2023

I guess defining the interface in a more central place makes sense if you anticipate more than one consumer. Like say supporting two transports HTTP & gRPC.

@wilfreddesert
Copy link
Author

Thanks for answering. I don't really understand what it simplifies though. If I understand correctly, the idea is to avoid copying the same interface in all so-called "driver adapters". But a little copying never killed nobody, quoting the Go proverbs.

Also, I'm not sure what is the benefit of returning the Service interface instead of a concrete implementation struct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants