Files
Umbraco-CMS/src/Umbraco.Core/Sync/ElectedServerRoleAccessor.cs
Nikolaj Brask-Nielsen 6d48091328 docs: XML warnings (#14663)
* chore: Fix XML warnings

* docs: Fix XML warnings

* docs: Fix XML in resource designer

* docs: Fix XML warnings

* Revert "docs: Fix XML in resource designer"

This reverts commit 8ea61c51ac161e1853ae080db7fe1b4d4cb4d2be.
2023-09-06 20:08:17 +02:00

30 lines
1.3 KiB
C#

using Umbraco.Cms.Core.Services;
namespace Umbraco.Cms.Core.Sync;
/// <summary>
/// Gets the current server's <see cref="ServerRole" /> based on active servers registered with
/// <see cref="IServerRegistrationService" />
/// </summary>
/// <remarks>
/// This is the default service which determines a server's role by using a master election process.
/// The scheduling publisher election process doesn't occur until just after startup so this election process doesn't
/// really affect the primary startup phase.
/// </remarks>
public sealed class ElectedServerRoleAccessor : IServerRoleAccessor
{
private readonly IServerRegistrationService _registrationService;
/// <summary>
/// Initializes a new instance of the <see cref="ElectedServerRoleAccessor" /> class.
/// </summary>
/// <param name="registrationService">The registration service.</param>
public ElectedServerRoleAccessor(IServerRegistrationService registrationService) => _registrationService =
registrationService ?? throw new ArgumentNullException(nameof(registrationService));
/// <summary>
/// Gets the role of the current server in the application environment.
/// </summary>
public ServerRole CurrentServerRole => _registrationService.GetCurrentServerRole();
}