tgstation-server
6.19.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
src
Tgstation.Server.Host
Authority
Core
ComponentInterfacingAuthorityBase.cs
Go to the documentation of this file.
1
using
System;
2
using
System.Threading.Tasks;
3
4
using
Microsoft.AspNetCore.Mvc;
5
using
Microsoft.Extensions.Logging;
6
7
using
Serilog.Context;
8
9
using
Tgstation.Server.Api.Models
;
10
using
Tgstation.Server.Host.Components
;
11
using
Tgstation.Server.Host.Database
;
12
using
Tgstation.Server.Host.Utils
;
13
14
namespace
Tgstation.Server.Host.Authority.Core
15
{
19
abstract
class
ComponentInterfacingAuthorityBase
:
AuthorityBase
20
{
24
readonly
IInstanceManager
instanceManager
;
25
32
protected
ComponentInterfacingAuthorityBase
(
33
IInstanceManager
instanceManager
,
34
IDatabaseContext
databaseContext,
35
ILogger<ComponentInterfacingAuthorityBase> logger)
36
: base(databaseContext, logger)
37
{
38
this.instanceManager =
instanceManager
??
throw
new
ArgumentNullException(nameof(
instanceManager
));
39
}
40
49
protected
async ValueTask<AuthorityResponse<TResult>>
WithComponentInstance<TResult>
(Func<
IInstanceCore
, ValueTask<
AuthorityResponse<TResult>
>> action,
long
instanceId)
50
{
51
using
var instanceReference =
instanceManager
.
GetInstanceReference
(instanceId);
52
using
(LogContext.PushProperty(
SerilogContextHelper
.
InstanceReferenceContextProperty
, instanceReference?.Uid))
53
{
54
if
(instanceReference ==
null
)
55
return
Conflict<TResult>
(
ErrorCode
.InstanceOffline);
56
return
await action(instanceReference);
57
}
58
}
59
}
60
}
Tgstation.Server.Host.Authority.Core.AuthorityBase
Base implementation of IAuthority.
Definition
AuthorityBase.cs:19
Tgstation.Server.Host.Authority.Core.AuthorityBase.Conflict< TResult >
static AuthorityResponse< TResult > Conflict< TResult >(ErrorCode errorCode, string? additionalData=null)
Generates a HttpFailureResponse.Conflict type AuthorityResponse<TResult>.
Tgstation.Server.Host.Authority.Core.AuthorityResponse
Represents a response from an authority.
Definition
AuthorityResponse{TResult}.cs:15
Tgstation.Server.Host.Authority.Core.ComponentInterfacingAuthorityBase
AuthorityBase for IAuthoritys that need to access IInstanceCores.
Definition
ComponentInterfacingAuthorityBase.cs:20
Tgstation.Server.Host.Authority.Core.ComponentInterfacingAuthorityBase.WithComponentInstance< TResult >
async ValueTask< AuthorityResponse< TResult > > WithComponentInstance< TResult >(Func< IInstanceCore, ValueTask< AuthorityResponse< TResult > > > action, long instanceId)
Run a given action with the relevant IInstance.
Definition
ComponentInterfacingAuthorityBase.cs:49
Tgstation.Server.Host.Authority.Core.ComponentInterfacingAuthorityBase.instanceManager
readonly IInstanceManager instanceManager
The IInstanceManager for the ComponentInterfacingAuthorityBase.
Definition
ComponentInterfacingAuthorityBase.cs:24
Tgstation.Server.Host.Authority.Core.ComponentInterfacingAuthorityBase.ComponentInterfacingAuthorityBase
ComponentInterfacingAuthorityBase(IInstanceManager instanceManager, IDatabaseContext databaseContext, ILogger< ComponentInterfacingAuthorityBase > logger)
Initializes a new instance of the ComponentInterfacingAuthorityBase class.
Definition
ComponentInterfacingAuthorityBase.cs:32
Tgstation.Server.Host.Utils.SerilogContextHelper
Helpers for manipulating the Serilog.Context.LogContext.
Definition
SerilogContextHelper.cs:7
Tgstation.Server.Host.Utils.SerilogContextHelper.InstanceReferenceContextProperty
const string InstanceReferenceContextProperty
The Serilog.Context.LogContext property name for Components.IInstanceReference.Uids.
Definition
SerilogContextHelper.cs:46
Tgstation.Server.Host.Components.IInstanceCore
For interacting with the instance services.
Definition
IInstanceCore.cs:16
Tgstation.Server.Host.Components.IInstanceManager
For managing IInstances.
Definition
IInstanceManager.cs:11
Tgstation.Server.Host.Components.IInstanceManager.GetInstanceReference
IInstanceReference? GetInstanceReference(long instanceId)
Get the IInstanceReference associated with given instanceId .
Tgstation.Server.Host.Database.IDatabaseContext
Represents the database.
Definition
IDatabaseContext.cs:17
Tgstation.Server.Api.Models
Definition
ChatChannel.cs:6
Tgstation.Server.Api.Models.ErrorCode
ErrorCode
Types of Response.ErrorMessageResponses that the API may return.
Definition
ErrorCode.cs:12
Tgstation.Server.Host.Authority.Core
Definition
AuthorityBase.cs:14
Tgstation.Server.Host.Components
Definition
ChannelMapping.cs:4
Tgstation.Server.Host.Database
Definition
DatabaseCollection.cs:10
Tgstation.Server.Host.Utils
Definition
GraphQLGitLabClient.cs:7
Generated by
1.9.8