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

consumer/producer: add interfaces #146

Open
bkeroackdsc opened this issue Jun 2, 2015 · 6 comments
Open

consumer/producer: add interfaces #146

bkeroackdsc opened this issue Jun 2, 2015 · 6 comments
Labels

Comments

@bkeroackdsc
Copy link

To facilitate testing, I've found myself abstracting out the go-nsq API so I can swap in mock implementations.

nsq.Producer/nsq.Consumer should be interfaces so that users don't have to create their own abstraction layer.

@jehiah jehiah added the question label Jun 2, 2015
@jehiah
Copy link
Member

jehiah commented Jun 2, 2015

@bkeroackdsc While i use something similar (see gist) I'm not convinced that this belongs in the go-nsq library (or that it would be easy to do so w/o breaking api compatibility promises).

Perhaps we could add a nsqtesting subpackage?

thoughts @mreiferson ?

@mreiferson
Copy link
Member

Yea, we couldn't return interfaces in the constructors without breaking compatibility, however we could introduce new interfaces that could provide a mechanism for speccing that out and being used in end-user tests?

@bkeroackdsc
Copy link
Author

@mreiferson That seems like a reasonable compromise.

@mreiferson mreiferson changed the title Producer/Consumer should be interfaces consumer/producer: add interfaces Aug 23, 2015
@sefasenturk95
Copy link

sefasenturk95 commented Mar 9, 2018

@mreiferson Are those new interfaces introduced already? I have to test a method that uses DeferredPublish..

@mreiferson
Copy link
Member

No, PRs welcome!

@fairyhunter13
Copy link

Guys, I think you don't need to make those interfaces if you want. But, could you make a public API for change the connections instance in producer and consumer? I think the other way (alternative) to test this nsq is to implement custom net memory listener with a pipe. So, that we could implement a custom mock for the nsq.

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

No branches or pull requests

5 participants