public DatabaseServerRegistrarAndMessengerComponent(IRuntimeState runtime, IServerRegistrar serverRegistrar, IServerMessenger serverMessenger, IServerRegistrationService registrationService, ILogger logger, IndexRebuilder indexRebuilder) { _runtime = runtime; _logger = logger; _registrationService = registrationService; _indexRebuilder = indexRebuilder; // create task runner for DatabaseServerRegistrar _registrar = serverRegistrar as DatabaseServerRegistrar; if (_registrar != null) { _touchTaskRunner = new BackgroundTaskRunner <IBackgroundTask>("ServerRegistration", new BackgroundTaskRunnerOptions { AutoStart = true }, logger); } // create task runner for BatchedDatabaseServerMessenger _messenger = serverMessenger as BatchedDatabaseServerMessenger; if (_messenger != null) { _processTaskRunner = new BackgroundTaskRunner <IBackgroundTask>("ServerInstProcess", new BackgroundTaskRunnerOptions { AutoStart = true }, logger); } }
/// <summary> /// Creates a partial service context with only some services (for tests). /// </summary> /// <remarks> /// <para>Using a true constructor for this confuses DI containers.</para> /// </remarks> public static ServiceContext CreatePartial( IContentService contentService = null, IMediaService mediaService = null, IContentTypeService contentTypeService = null, IMediaTypeService mediaTypeService = null, IDataTypeService dataTypeService = null, IFileService fileService = null, ILocalizationService localizationService = null, IPackagingService packagingService = null, IEntityService entityService = null, IRelationService relationService = null, IMemberGroupService memberGroupService = null, IMemberTypeService memberTypeService = null, IMemberService memberService = null, IUserService userService = null, ISectionService sectionService = null, IApplicationTreeService treeService = null, ITagService tagService = null, INotificationService notificationService = null, ILocalizedTextService localizedTextService = null, IAuditService auditService = null, IDomainService domainService = null, IMacroService macroService = null, IPublicAccessService publicAccessService = null, IExternalLoginService externalLoginService = null, IServerRegistrationService serverRegistrationService = null, IRedirectUrlService redirectUrlService = null, IConsentService consentService = null) { Lazy <T> Lazy <T>(T service) => service == null ? null : new Lazy <T>(() => service); return(new ServiceContext( Lazy(publicAccessService), Lazy(domainService), Lazy(auditService), Lazy(localizedTextService), Lazy(tagService), Lazy(contentService), Lazy(userService), Lazy(memberService), Lazy(mediaService), Lazy(contentTypeService), Lazy(mediaTypeService), Lazy(dataTypeService), Lazy(fileService), Lazy(localizationService), Lazy(packagingService), Lazy(serverRegistrationService), Lazy(entityService), Lazy(relationService), Lazy(treeService), Lazy(sectionService), Lazy(macroService), Lazy(memberTypeService), Lazy(memberGroupService), Lazy(notificationService), Lazy(externalLoginService), Lazy(redirectUrlService), Lazy(consentService))); }
public DatabaseServerRegistrarAndMessengerComponent(IRuntimeState runtime, IServerRegistrar serverRegistrar, IServerMessenger serverMessenger, IServerRegistrationService registrationService, ILogger logger, IndexRebuilder indexRebuilder) { _registrar = serverRegistrar as DatabaseServerRegistrar; if (_registrar == null) { throw new Exception("panic: registar."); } _messenger = serverMessenger as BatchedDatabaseServerMessenger; if (_messenger == null) { throw new Exception("panic: messenger"); } _runtime = runtime; _logger = logger; _registrationService = registrationService; _indexRebuilder = indexRebuilder; _touchTaskRunner = new BackgroundTaskRunner <IBackgroundTask>("ServerRegistration", new BackgroundTaskRunnerOptions { AutoStart = true }, logger); _processTaskRunner = new BackgroundTaskRunner <IBackgroundTask>("ServerInstProcess", new BackgroundTaskRunnerOptions { AutoStart = true }, logger); }
/// <summary> /// Initializes a new instance of the <see cref="TouchServerTask"/> class. /// </summary> public TouchServerTask(IBackgroundTaskRunner <RecurringTaskBase> runner, int delayMilliseconds, int periodMilliseconds, IServerRegistrationService svc, DatabaseServerRegistrar registrar, string serverAddress, ILogger logger) : base(runner, delayMilliseconds, periodMilliseconds) { _svc = svc ?? throw new ArgumentNullException(nameof(svc)); _registrar = registrar; _serverAddress = serverAddress; _logger = logger; }
private IBackgroundTask RegisterTouchServer(IServerRegistrationService registrationService, string serverAddress) { var task = new TouchServerTask(_touchTaskRunner, 15000, //delay before first execution _registrar.Options.RecurringSeconds * 1000, //amount of ms between executions registrationService, _registrar, serverAddress, _logger); _touchTaskRunner.TryAdd(task); return(task); }
/// <summary> /// Initializes a new instance of the <see cref="RecurringTaskBase"/> class. /// </summary> /// <param name="runner">The task runner.</param> /// <param name="delayMilliseconds">The delay.</param> /// <param name="periodMilliseconds">The period.</param> /// <param name="svc"></param> /// <param name="registrar"></param> /// <param name="serverAddress"></param> /// <remarks>The task will repeat itself periodically. Use this constructor to create a new task.</remarks> public TouchServerTask(IBackgroundTaskRunner <RecurringTaskBase> runner, int delayMilliseconds, int periodMilliseconds, IServerRegistrationService svc, DatabaseServerRegistrar registrar, string serverAddress) : base(runner, delayMilliseconds, periodMilliseconds) { if (svc == null) { throw new ArgumentNullException("svc"); } _svc = svc; _registrar = registrar; _serverAddress = serverAddress; }
/// <summary> /// Initializes a new instance of the <see cref="TouchServerTask"/> class. /// </summary> /// <param name="runtimeState">Representation of the state of the Umbraco runtime.</param> /// <param name="serverRegistrationService">Services for server registrations.</param> /// <param name="requestAccessor">Accessor for the current request.</param> /// <param name="logger">The typed logger.</param> /// <param name="globalSettings">The configuration for global settings.</param> public TouchServerTask( IRuntimeState runtimeState, IServerRegistrationService serverRegistrationService, IHostingEnvironment hostingEnvironment, ILogger <TouchServerTask> logger, IOptions <GlobalSettings> globalSettings) : base(globalSettings.Value.DatabaseServerRegistrar.WaitTimeBetweenCalls, TimeSpan.FromSeconds(15)) { _runtimeState = runtimeState; _serverRegistrationService = serverRegistrationService ?? throw new ArgumentNullException(nameof(serverRegistrationService)); _hostingEnvironment = hostingEnvironment; _logger = logger; _globalSettings = globalSettings.Value; }
public TouchServerTask( IRuntimeState runtimeState, IServerRegistrationService serverRegistrationService, IHostingEnvironment hostingEnvironment, ILogger <TouchServerTask> logger, IOptions <GlobalSettings> globalSettings) : this( runtimeState, serverRegistrationService, hostingEnvironment, logger, globalSettings, StaticServiceProvider.Instance.GetRequiredService <IServerRoleAccessor>()) { }
/// <summary> /// Initializes a new instance of the <see cref="TouchServerTask"/> class. /// </summary> /// <param name="runtimeState">Representation of the state of the Umbraco runtime.</param> /// <param name="serverRegistrationService">Services for server registrations.</param> /// <param name="requestAccessor">Accessor for the current request.</param> /// <param name="logger">The typed logger.</param> /// <param name="globalSettings">The configuration for global settings.</param> public TouchServerTask( IRuntimeState runtimeState, IServerRegistrationService serverRegistrationService, IHostingEnvironment hostingEnvironment, ILogger <TouchServerTask> logger, IOptionsMonitor <GlobalSettings> globalSettings, IServerRoleAccessor serverRoleAccessor) : base(logger, globalSettings.CurrentValue.DatabaseServerRegistrar.WaitTimeBetweenCalls, TimeSpan.FromSeconds(15)) { _runtimeState = runtimeState; _serverRegistrationService = serverRegistrationService ?? throw new ArgumentNullException(nameof(serverRegistrationService)); _hostingEnvironment = hostingEnvironment; _logger = logger; _globalSettings = globalSettings.CurrentValue; globalSettings.OnChange(x => { _globalSettings = x; ChangePeriod(x.DatabaseServerRegistrar.WaitTimeBetweenCalls); }); _serverRoleAccessor = serverRoleAccessor; }
private void EnsureServerRegistered() { IServerRegistrationService serverRegistrationService = GetRequiredService <IServerRegistrationService>(); serverRegistrationService.TouchServer("http://localhost", TimeSpan.FromMinutes(10)); }
/// <summary> /// Initializes a new instance of the <see cref="ElectedServerRoleAccessor"/> class. /// </summary> /// <param name="registrationService">The registration service.</param> /// <param name="options">Some options.</param> public ElectedServerRoleAccessor(IServerRegistrationService registrationService) => _registrationService = registrationService ?? throw new ArgumentNullException(nameof(registrationService));
/// <summary> /// Initializes a new instance of the <see cref="ElectedServerRoleAccessor" /> class. /// </summary> /// <param name="registrationService">The registration service.</param> /// <param name="options">Some options.</param> public ElectedServerRoleAccessor(IServerRegistrationService registrationService) => _registrationService =