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

JobManager.JobException dependency injection #91

Closed
MrGold opened this issue Jul 28, 2016 · 1 comment
Closed

JobManager.JobException dependency injection #91

MrGold opened this issue Jul 28, 2016 · 1 comment

Comments

@MrGold
Copy link

MrGold commented Jul 28, 2016

Hello,

To log job exceptions I've written following lines;

JobManager.JobException += JobManager_JobException;
private static void JobManager_JobException(JobExceptionInfo obj)
{
            ILogger logger = EngineContext.Current.Resolve<ILogger>();
            logger.Error(obj.Exception);
}

It is working but i cannot inject ILogger here.I have to use service locator which i prefer to avoid.
Is there any other way in FluentScheduler that i can inject dependencies and use them in JobException event?

Thanks,

@tallesl
Copy link
Contributor

tallesl commented Jul 29, 2016

Nope. You have to keep doing like that.

There are two distinct schools on designing an API:

  • One is the "enterprise" way, the library would be very opinionated on how you talk to it, demanding that you implement specific interfaces and having a say on the designing of your own code base.
  • The other is being more "lightweight", using simple unopinionated techniques for talking to your code, like a simple event field, leaving the actual design of your code base entirely on your shoulders.

You can see the first as a "framework" and the latter more as a "library". I'm on the library side.

I'm closing this issue but feel free to comment further on it.

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