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;
|
||||
|
||||
public sealed class NodeEnrollmentService
|
||||
public sealed class NodeEnrollmentService : IDisposable
|
||||
{
|
||||
private readonly IOptions<ControlOptions> _options;
|
||||
private readonly ControlStore _store;
|
||||
|
|
@ -59,13 +59,9 @@ public sealed class NodeEnrollmentService
|
|||
_broker.Publish(
|
||||
"agent.enrollment_code.issued",
|
||||
nodeId,
|
||||
JsonSerializer.Serialize(new
|
||||
{
|
||||
node_id = nodeId,
|
||||
actor,
|
||||
node_address = nodeAddress,
|
||||
expires_at = expiresAt
|
||||
}));
|
||||
JsonSerializer.Serialize(
|
||||
new NodeEnrollmentCodeIssuedDetails(nodeId, actor, nodeAddress, expiresAt),
|
||||
SmmJsonContext.Default.NodeEnrollmentCodeIssuedDetails));
|
||||
|
||||
var code = string.Join(".",
|
||||
"SMMNODE2",
|
||||
|
|
@ -220,4 +216,9 @@ public sealed class NodeEnrollmentService
|
|||
.Replace('+', '-')
|
||||
.Replace('/', '_');
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_meshLock.Dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,3 +5,9 @@ public sealed record NodeEnrollmentCodeResponse(
|
|||
string Code,
|
||||
string CaFingerprint,
|
||||
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(NodeEnrollmentCodeResponse))]
|
||||
[JsonSerializable(typeof(NodeEnrollmentCodeIssuedDetails))]
|
||||
public sealed partial class SmmJsonContext : JsonSerializerContext;
|
||||
|
|
|
|||
Loading…
Reference in a new issue