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

Correctly implementing IJobsQueueService #7335

Closed
wants to merge 1 commit into from

Conversation

kumards
Copy link
Contributor

@kumards kumards commented Oct 20, 2016

Fix for #4718. IJobsQueueService supposed to be just a service than an event handler.

IJobsQueueService  supposed to be a service than an event handler.
@sebastienros
Copy link
Member

sebastienros commented Oct 20, 2016

Why? Isn't the solution to fix the bug in the event bus? That would be a non-breaking change this way.

@kumards
Copy link
Contributor Author

kumards commented Oct 20, 2016

Yeah, this fix solved my problem. I believe by mistake IJobsQueueService inherited IEventHandler instead of IDependency.

@sebastienros
Copy link
Member

No, it's by design, on purpose that it's an IEventHandler, but there is a bug in event handlers, which needs to be fixed, c.f. linked issues. I am closing this PR, please create one that fixes the event handler, it should be explained in this one: #4584

@kumards
Copy link
Contributor Author

kumards commented Oct 20, 2016

Does that mean, there can be multiple implementations of IJobsQueueService?

I guess if IJobsQueueServiceis going to inherit from IEventHandler, then it has to be injected like collection IEnumerable<IJobsQueueService> jobsQueueServices, not as a single instance.

@sfmskywalker
Copy link
Member

sfmskywalker commented Oct 20, 2016

Although technically speaking one could of course create multiple implementations, you don't inject an enumerable, but a single instance. This baffled me too at first. Check this out for more details (including the comments): http://www.ideliverable.com/blog/ieventhandler

@kumards kumards deleted the patch-8 branch October 20, 2016 21:07
@kumards
Copy link
Contributor Author

kumards commented Oct 21, 2016

I am just curious, why is it intentionally inheriting from IEventHandler when multiple implementations of it is not expected?

@sfmskywalker
Copy link
Member

The reason is that this enables other modules to use the IJobsQueueService without having to actually add a project reference to Orchard.JobsQueue. This is actually a very nice pattern to implement modules with truly optional dependencies, where the dependent module would still build even if there was no Orchard.JobsQueue available. The only sad part is the poor choice of name, because to your point, IEventHandler would indicate a handler of an event or events. I wouldn't be surprised if this will be renamed in O2, or if at least an additional interface with a more appropriate name will be provided that leverages the same event bus in the same way.

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

Successfully merging this pull request may close these issues.

4 participants