public void RegisterBackgroundServices(IBackgroundServiceRegistry registry) { //OxiteConfigurationSection config = container.Resolve<OxiteConfigurationSection>(); //OxiteModuleConfigurationElement moduleConfiguration = config.Modules.Module(this.GetType()); //registry.Add<InProcessBackgroundServiceExecutor, SendMessages>(moduleConfiguration, "SendTrackbacks", TimeSpan.FromMinutes(1)); }
public void Cleanup(IDictionary <string, object> state) { IBackgroundServiceRegistry backgroundServicesRegistry = this.container.Resolve <BackgroundServiceRegistry>(); foreach (IBackgroundServiceExecutor executor in backgroundServicesRegistry.GetBackgroundServices()) { executor.Stop(); } }
public BotService(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; _messageHandler = _serviceProvider.GetRequiredService <IMessageHandler>(); _requestDispatcher = _serviceProvider.GetRequiredService <IRequestDispatcher>(); _userRepo = _serviceProvider.GetRequiredService <IUserRepository>(); _logger = Log.Logger.ForContext <BotService>(); _responseBuilder = _serviceProvider.GetRequiredService <IResponseBuilder>(); _appSettings = _serviceProvider.GetRequiredService <IOptions <AppSettings> >().Value; _backgroundServiceRegistry = _serviceProvider.GetRequiredService <IBackgroundServiceRegistry>(); }
public void Execute(IDictionary <string, object> state) { //TODO: (erikpo) Change the following to load up background services that are registered in Oxite.config instead of just looking in modules since they can be anywhere IModulesLoaded modulesLoaded = container.Resolve <IModulesLoaded>(); IBackgroundServiceRegistry backgroundServicesRegistry = this.container.Resolve <BackgroundServiceRegistry>(); foreach (IOxiteModule module in modulesLoaded.GetModules()) { IOxiteBackgroundService backgroundServices = module as IOxiteBackgroundService; if (backgroundServices != null) { backgroundServices.RegisterBackgroundServices(backgroundServicesRegistry); } } container.RegisterInstance(backgroundServicesRegistry); foreach (IBackgroundServiceExecutor executor in backgroundServicesRegistry.GetBackgroundServices()) { executor.Start(); } }