mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-26 15:35:55 +03:00
[GH-ISSUE #282] [FEATURE REQUEST] Use interfaces #2135
Labels
No labels
CLI
bug
designing
documentation
duplicate
enhancement
good first issue
good first issue
help wanted
idea
invalid
investigate
needs-more-info
performance
pr-welcome
pull-request
question
wontfix
work in progress
work in progress
work-around-available
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/asynq#2135
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mrsufgi on GitHub (Jun 21, 2021).
Original GitHub issue: https://github.com/hibiken/asynq/issues/282
Originally assigned to: @hibiken on GitHub.
Is your feature request related to a problem? Please describe.
Im using asynq in several projects and I find myself create partial interfaces for asynq.Client (type) so I can mock on my unit tests. It's tedius, partial and redunant and could be helpful to have "Official" interfaces returned from NewClient function
further reference on how do you mock uninterfaced dependencies
https://dev.to/jonfriesen/mocking-dependencies-in-go-1h4d
Describe the solution you'd like
client.go -> callings
NewClientreturnsAsynqClientinterface instead of Client type (struct)Thanks for this awesome package! <3
@crossworth commented on GitHub (Jul 10, 2021):
Hi, I don't think we improve the library by doing this. The idiomatic way is for the consumer to define the interface, the reference that you pointed show that as well, I know that is a bit tedius doing that for every project, but you could use a interface generator tool or create a wrapper around the AsyncClient.
For more references see the links below:
There is a video where William Kennedy talks exactly about this scenario, but I couldn't find it.
Anyway, that's my opinion.
@hibiken commented on GitHub (Jul 10, 2021):
@mrsufgi Thank you for opening this issue! While I can related to the pain of defining interface in every project, I agree with @crossworth in that we shouldn't make this API change.
These feedback on APIs are very useful, so if you have more please don't hesitate to open an issue!
@mrsufgi commented on GitHub (Jul 11, 2021):
Thank you for your answers! I agree, if interfaces are only meant for testing, I can use something like
https://github.com/vburenin/ifacemaker
To easily generate them from structs :)
🥳