fix(control): implement IDisposable on NodeEnrollmentService and register event payload in SmmJsonContext
This commit is contained in:
parent
aa8da317cf
commit
93eb507f7a
3 changed files with 16 additions and 8 deletions
|
|
@ -6,7 +6,7 @@ using ServerMonitorManager.Core;
|
||||||
|
|
||||||
namespace ServerMonitorManager.Control;
|
namespace ServerMonitorManager.Control;
|
||||||
|
|
||||||
public sealed class NodeEnrollmentService
|
public sealed class NodeEnrollmentService : IDisposable
|
||||||
{
|
{
|
||||||
private readonly IOptions<ControlOptions> _options;
|
private readonly IOptions<ControlOptions> _options;
|
||||||
private readonly ControlStore _store;
|
private readonly ControlStore _store;
|
||||||
|
|
@ -59,13 +59,9 @@ public sealed class NodeEnrollmentService
|
||||||
_broker.Publish(
|
_broker.Publish(
|
||||||
"agent.enrollment_code.issued",
|
"agent.enrollment_code.issued",
|
||||||
nodeId,
|
nodeId,
|
||||||
JsonSerializer.Serialize(new
|
JsonSerializer.Serialize(
|
||||||
{
|
new NodeEnrollmentCodeIssuedDetails(nodeId, actor, nodeAddress, expiresAt),
|
||||||
node_id = nodeId,
|
SmmJsonContext.Default.NodeEnrollmentCodeIssuedDetails));
|
||||||
actor,
|
|
||||||
node_address = nodeAddress,
|
|
||||||
expires_at = expiresAt
|
|
||||||
}));
|
|
||||||
|
|
||||||
var code = string.Join(".",
|
var code = string.Join(".",
|
||||||
"SMMNODE2",
|
"SMMNODE2",
|
||||||
|
|
@ -220,4 +216,9 @@ public sealed class NodeEnrollmentService
|
||||||
.Replace('+', '-')
|
.Replace('+', '-')
|
||||||
.Replace('/', '_');
|
.Replace('/', '_');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_meshLock.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,9 @@ public sealed record NodeEnrollmentCodeResponse(
|
||||||
string Code,
|
string Code,
|
||||||
string CaFingerprint,
|
string CaFingerprint,
|
||||||
DateTimeOffset ExpiresAt);
|
DateTimeOffset ExpiresAt);
|
||||||
|
|
||||||
|
public sealed record NodeEnrollmentCodeIssuedDetails(
|
||||||
|
string NodeId,
|
||||||
|
string Actor,
|
||||||
|
string NodeAddress,
|
||||||
|
DateTimeOffset ExpiresAt);
|
||||||
|
|
|
||||||
|
|
@ -58,4 +58,5 @@ namespace ServerMonitorManager.Core;
|
||||||
[JsonSerializable(typeof(ProvisioningEvent))]
|
[JsonSerializable(typeof(ProvisioningEvent))]
|
||||||
[JsonSerializable(typeof(ProvisioningEvent[]))]
|
[JsonSerializable(typeof(ProvisioningEvent[]))]
|
||||||
[JsonSerializable(typeof(NodeEnrollmentCodeResponse))]
|
[JsonSerializable(typeof(NodeEnrollmentCodeResponse))]
|
||||||
|
[JsonSerializable(typeof(NodeEnrollmentCodeIssuedDetails))]
|
||||||
public sealed partial class SmmJsonContext : JsonSerializerContext;
|
public sealed partial class SmmJsonContext : JsonSerializerContext;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue