DI Examples not helpful or realistic #1878
Replies: 8 comments
-
The ASP.NET Core example site shows injection of |
Beta Was this translation helpful? Give feedback.
-
Thank you for the response. I have tried that and had no luck. If I use a named scheduler in my config, the factory returns null. If I try to get the default scheduler, it gets me a default scheduler with none of the config I set (using correct job store etc.)
|
Beta Was this translation helpful? Give feedback.
-
What is this: builder.Services.AddTransient<ISchedulerFactory, StdSchedulerFactory>(); Quartz handles this for you, scheduler factory is anyway singleton, not transient. Try removing it. |
Beta Was this translation helpful? Give feedback.
-
That is me being a dunce. It works. Thanks for the help. That being said injecting a "factory" into a class to "instantiate" a service sort of defeats the purpose of DI in the first place. |
Beta Was this translation helpful? Give feedback.
-
Well what scheduler instance should we inject then? There can be multiple. If it helps with the mental model think it as locator or accessor like there's |
Beta Was this translation helpful? Give feedback.
-
@lahma |
Beta Was this translation helpful? Give feedback.
-
@devbased probably yes, the default one isn't provided due to current integration being generic (also |
Beta Was this translation helpful? Give feedback.
-
I think one-time blocking async work is acceptable in general |
Beta Was this translation helpful? Give feedback.
-
Trying to incorporate this package into our work and the only example for DI displays all the functionality from within the DI container. Not sure how this is helpful, considering the vast majority of jobs will be scheduled during the lifecycle of the app, from the service layer for instance, not before it even starts. There's no example on how to access the scheduler or scheduler factory from outside the container, as most people probably need. Not only that, the scheduler itself is not even accessible/ instantiated until after the app runs - how is that helpful, when it can only be accessed from the DI builder as far as I can tell? I must be missing something, but the current documentation seems woefully lacking. I showed my lead and he was also confused and almost said don't use the package, which is a shame.
Beta Was this translation helpful? Give feedback.
All reactions