tgstation-server 6.17.0
The /tg/station 13 server suite
|
Public Member Functions | |||||||
PortAllocator (IServerPortProvider serverPortProvider, IDatabaseContextFactory databaseContextFactory, IPlatformIdentifier platformIdentifier, IOptions< SwarmConfiguration > swarmConfigurationOptions, ILogger< PortAllocator > logger) | |||||||
Initializes a new instance of the PortAllocator class. | |||||||
void | Dispose () | ||||||
async ValueTask< ushort?> | GetAvailablePort (ushort basePort, bool checkOne, CancellationToken cancellationToken) | ||||||
Gets a port not currently in use by TGS.
| |||||||
Private Member Functions | |
async ValueTask< ushort?> | GetAvailablePort (IDatabaseContext databaseContext, ushort basePort, bool checkOne, CancellationToken cancellationToken) |
Gets a port not currently in use by TGS. | |
Private Attributes | |
readonly IServerPortProvider | serverPortProvider |
The IServerPortProvider for the PortAllocator. | |
readonly IDatabaseContextFactory | databaseContextFactory |
The IDatabaseContext for the PortAllocator. | |
readonly IPlatformIdentifier | platformIdentifier |
The IPlatformIdentifier for the PortAllocator. | |
readonly ILogger< PortAllocator > | logger |
The ILogger for the PortAllocator. | |
readonly SwarmConfiguration | swarmConfiguration |
The SwarmConfiguration for the PortAllocator. | |
readonly SemaphoreSlim | allocatorLock |
The SemaphoreSlim used to serialized port requisition requests. | |
Definition at line 20 of file PortAllocator.cs.
Tgstation.Server.Host.Utils.PortAllocator.PortAllocator | ( | IServerPortProvider | serverPortProvider, |
IDatabaseContextFactory | databaseContextFactory, | ||
IPlatformIdentifier | platformIdentifier, | ||
IOptions< SwarmConfiguration > | swarmConfigurationOptions, | ||
ILogger< PortAllocator > | logger | ||
) |
Initializes a new instance of the PortAllocator class.
serverPortProvider | The value of serverPortProvider. |
databaseContextFactory | The value of databaseContextFactory. |
platformIdentifier | The value of platformIdentifier. |
swarmConfigurationOptions | The IOptions<TOptions> containing the value of swarmConfiguration. |
logger | The value of logger. |
Definition at line 60 of file PortAllocator.cs.
References Tgstation.Server.Host.Utils.PortAllocator.allocatorLock, Tgstation.Server.Host.Utils.PortAllocator.databaseContextFactory, Tgstation.Server.Host.Utils.PortAllocator.logger, Tgstation.Server.Host.Utils.PortAllocator.platformIdentifier, Tgstation.Server.Host.Utils.PortAllocator.serverPortProvider, and Tgstation.Server.Host.Utils.PortAllocator.swarmConfiguration.
void Tgstation.Server.Host.Utils.PortAllocator.Dispose | ( | ) |
|
private |
Gets a port not currently in use by TGS.
databaseContext | The IDatabaseContext to use. |
basePort | The port to check first. Will not allocate a port lower than this. |
checkOne | If only basePort should be checked and no others. |
cancellationToken | The CancellationToken for the operation. |
null
on failure.Definition at line 97 of file PortAllocator.cs.
References Tgstation.Server.Host.Extensions.SocketExtensions.BindTest(), Tgstation.Server.Host.Database.IDatabaseContext.DreamDaemonSettings, Tgstation.Server.Host.Database.IDatabaseContext.DreamMakerSettings, Tgstation.Server.Host.Core.IServerPortProvider.HttpApiPort, Tgstation.Server.Api.Models.Internal.SwarmServer.Identifier, Tgstation.Server.Host.Utils.PortAllocator.logger, Tgstation.Server.Host.Utils.PortAllocator.platformIdentifier, Tgstation.Server.Host.Utils.PortAllocator.serverPortProvider, and Tgstation.Server.Host.Utils.PortAllocator.swarmConfiguration.
async ValueTask< ushort?> Tgstation.Server.Host.Utils.PortAllocator.GetAvailablePort | ( | ushort | basePort, |
bool | checkOne, | ||
CancellationToken | cancellationToken | ||
) |
Gets a port not currently in use by TGS.
basePort | The port to check first. Will not allocate a port lower than this. |
checkOne | If only basePort should be checked and no others. |
cancellationToken | The CancellationToken for the operation. |
null
on failure.Implements Tgstation.Server.Host.Utils.IPortAllocator.
Definition at line 80 of file PortAllocator.cs.
References Tgstation.Server.Host.Utils.PortAllocator.allocatorLock, Tgstation.Server.Host.Utils.PortAllocator.databaseContextFactory, Tgstation.Server.Host.Utils.PortAllocator.GetAvailablePort(), Tgstation.Server.Host.Utils.SemaphoreSlimContext.Lock(), and Tgstation.Server.Host.Database.IDatabaseContextFactory.UseContext().
Referenced by Tgstation.Server.Host.Utils.PortAllocator.GetAvailablePort().
|
private |
The SemaphoreSlim used to serialized port requisition requests.
Definition at line 50 of file PortAllocator.cs.
Referenced by Tgstation.Server.Host.Utils.PortAllocator.GetAvailablePort(), and Tgstation.Server.Host.Utils.PortAllocator.PortAllocator().
|
private |
The IDatabaseContext for the PortAllocator.
Definition at line 30 of file PortAllocator.cs.
Referenced by Tgstation.Server.Host.Utils.PortAllocator.GetAvailablePort(), and Tgstation.Server.Host.Utils.PortAllocator.PortAllocator().
|
private |
The ILogger for the PortAllocator.
Definition at line 40 of file PortAllocator.cs.
Referenced by Tgstation.Server.Host.Utils.PortAllocator.GetAvailablePort(), and Tgstation.Server.Host.Utils.PortAllocator.PortAllocator().
|
private |
The IPlatformIdentifier for the PortAllocator.
Definition at line 35 of file PortAllocator.cs.
Referenced by Tgstation.Server.Host.Utils.PortAllocator.GetAvailablePort(), and Tgstation.Server.Host.Utils.PortAllocator.PortAllocator().
|
private |
The IServerPortProvider for the PortAllocator.
Definition at line 25 of file PortAllocator.cs.
Referenced by Tgstation.Server.Host.Utils.PortAllocator.GetAvailablePort(), and Tgstation.Server.Host.Utils.PortAllocator.PortAllocator().
|
private |
The SwarmConfiguration for the PortAllocator.
Definition at line 45 of file PortAllocator.cs.
Referenced by Tgstation.Server.Host.Utils.PortAllocator.GetAvailablePort(), and Tgstation.Server.Host.Utils.PortAllocator.PortAllocator().