Publish runtime drain operations surface
This commit is contained in:
parent
9fbc77e4e9
commit
1f88375a7e
9 changed files with 257 additions and 11 deletions
|
|
@ -37,6 +37,7 @@ public static class AetheriaDocumentRegistry
|
|||
CultNetDocumentBinding.ForDocument<AetheriaRunState>(registry),
|
||||
CultNetDocumentBinding.ForDocument<AetheriaZoneState>(registry),
|
||||
CultNetDocumentBinding.ForDocument<AetheriaEntitySnapshot>(registry),
|
||||
CultNetDocumentBinding.ForDocument<AetheriaRuntimeCommitDrainStatus>(registry),
|
||||
CultNetDocumentBinding.ForDocument<EveSurfaceState>(registry)
|
||||
});
|
||||
}
|
||||
|
|
@ -56,6 +57,7 @@ public static class AetheriaDocumentRegistry
|
|||
typeof(AetheriaRunState),
|
||||
typeof(AetheriaZoneState),
|
||||
typeof(AetheriaEntitySnapshot),
|
||||
typeof(AetheriaRuntimeCommitDrainStatus),
|
||||
typeof(EveSurfaceState)
|
||||
];
|
||||
}
|
||||
|
|
|
|||
80
Aetheria.State/AetheriaOperationsSurfaceProjector.cs
Normal file
80
Aetheria.State/AetheriaOperationsSurfaceProjector.cs
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
using Aetheria.State.Documents;
|
||||
|
||||
namespace Aetheria.State;
|
||||
|
||||
public static class AetheriaOperationsSurfaceProjector
|
||||
{
|
||||
public const string SurfaceKey = "eve:surface:aetheria.operations";
|
||||
public const string SurfaceId = "aetheria.operations";
|
||||
|
||||
public static EveSurfaceState Build(AetheriaRuntimeCommitDrainStatus drainStatus, long version = 1)
|
||||
{
|
||||
return new EveSurfaceState
|
||||
{
|
||||
ProviderId = "aetheria",
|
||||
ProviderKind = "game.runtime",
|
||||
Title = "Aetheria Operations",
|
||||
Version = version,
|
||||
UpdatedAtUtc = drainStatus.LastPollAtUtc,
|
||||
Surface = new EveSurface
|
||||
{
|
||||
Id = SurfaceId,
|
||||
Root = Node(
|
||||
"aetheria.operations.root",
|
||||
"surface",
|
||||
[],
|
||||
Node(
|
||||
"aetheria.operations.commitDrain",
|
||||
"card",
|
||||
[("title", "Runtime Commit Drain")],
|
||||
Metric("commitDrain.status", "Status", drainStatus.Status),
|
||||
Metric("commitDrain.pending", "Pending Before Apply", drainStatus.PendingBeforeApply.ToString()),
|
||||
Metric("commitDrain.applied", "Commands Applied", drainStatus.CommandsApplied.ToString()),
|
||||
Metric("commitDrain.settings", "Settings", drainStatus.AppliedPlayerSettings.ToString()),
|
||||
Metric("commitDrain.loadouts", "Loadouts", drainStatus.AppliedLoadoutTemplates.ToString()),
|
||||
Metric("commitDrain.runs", "Run Checkpoints", drainStatus.AppliedRunCheckpoints.ToString()),
|
||||
Metric("commitDrain.failures", "Consecutive Failures", drainStatus.ConsecutiveFailures.ToString()),
|
||||
Row(
|
||||
"commitDrain.last",
|
||||
("runtime", drainStatus.RuntimeId),
|
||||
("lastPoll", drainStatus.LastPollAtUtc),
|
||||
("lastApplied", drainStatus.LastAppliedAtUtc),
|
||||
("error", drainStatus.LastError))))
|
||||
},
|
||||
Commands =
|
||||
[
|
||||
new EveCommandTemplate
|
||||
{
|
||||
Command = "aetheria.operations.refresh",
|
||||
Label = "Refresh",
|
||||
Transport = "cultmesh"
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
private static EveSurfaceComponent Metric(string id, string label, string value)
|
||||
{
|
||||
return Node(id, "metric", [("label", label), ("value", value)]);
|
||||
}
|
||||
|
||||
private static EveSurfaceComponent Row(string id, params (string Key, string Value)[] props)
|
||||
{
|
||||
return Node(id, "row", props);
|
||||
}
|
||||
|
||||
private static EveSurfaceComponent Node(
|
||||
string id,
|
||||
string kind,
|
||||
(string Key, string Value)[] props,
|
||||
params EveSurfaceComponent[] children)
|
||||
{
|
||||
return new EveSurfaceComponent
|
||||
{
|
||||
Id = id,
|
||||
Kind = kind,
|
||||
Props = props.ToDictionary(prop => prop.Key, prop => prop.Value),
|
||||
Children = children
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -173,6 +173,16 @@ public sealed class AetheriaStateNode : IAsyncDisposable, IDisposable
|
|||
return Database.GetAsync<EveSurfaceState>(new CultRecordKey(AetheriaCatalogSurfaceProjector.SurfaceKey));
|
||||
}
|
||||
|
||||
public Task<CultRecordHandle<EveSurfaceState>> PutOperationsSurfaceAsync(EveSurfaceState surface)
|
||||
{
|
||||
return Database.PutAsync(new CultRecordKey(AetheriaOperationsSurfaceProjector.SurfaceKey), surface);
|
||||
}
|
||||
|
||||
public Task<EveSurfaceState?> GetOperationsSurfaceAsync()
|
||||
{
|
||||
return Database.GetAsync<EveSurfaceState>(new CultRecordKey(AetheriaOperationsSurfaceProjector.SurfaceKey));
|
||||
}
|
||||
|
||||
public Task<CultRecordHandle<AetheriaPlayerSettings>> PutPlayerSettingsAsync(AetheriaPlayerSettings settings)
|
||||
{
|
||||
return Database.PutAsync(new CultRecordKey("global:aetheria.player_settings.v1"), settings);
|
||||
|
|
@ -227,6 +237,18 @@ public sealed class AetheriaStateNode : IAsyncDisposable, IDisposable
|
|||
return Database.GetAsync<AetheriaEntitySnapshot>(key);
|
||||
}
|
||||
|
||||
public Task<CultRecordHandle<AetheriaRuntimeCommitDrainStatus>> PutRuntimeCommitDrainStatusAsync(
|
||||
AetheriaRuntimeCommitDrainStatus status)
|
||||
{
|
||||
return Database.PutAsync(new CultRecordKey("global:aetheria.runtime_commit_drain_status.v1"), status);
|
||||
}
|
||||
|
||||
public Task<AetheriaRuntimeCommitDrainStatus?> GetRuntimeCommitDrainStatusAsync()
|
||||
{
|
||||
return Database.GetAsync<AetheriaRuntimeCommitDrainStatus>(
|
||||
new CultRecordKey("global:aetheria.runtime_commit_drain_status.v1"));
|
||||
}
|
||||
|
||||
public Task FlushAsync(bool soft = false)
|
||||
{
|
||||
return _node.FlushAsync(soft);
|
||||
|
|
|
|||
51
Aetheria.State/Documents/AetheriaRuntimeCommitDrainStatus.cs
Normal file
51
Aetheria.State/Documents/AetheriaRuntimeCommitDrainStatus.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
using GameCult.Caching;
|
||||
using MessagePack;
|
||||
|
||||
namespace Aetheria.State.Documents;
|
||||
|
||||
[CultDocument("aetheria.runtime_commit_drain_status", "aetheria.runtime_commit_drain_status.v1")]
|
||||
[CultGlobal]
|
||||
[MessagePackObject]
|
||||
public sealed class AetheriaRuntimeCommitDrainStatus
|
||||
{
|
||||
[Key(0)]
|
||||
[CultName]
|
||||
public string Name { get; set; } = "Aetheria runtime commit drain";
|
||||
|
||||
[Key(1)]
|
||||
[CultIndex("runtimeId")]
|
||||
public string RuntimeId { get; set; } = "";
|
||||
|
||||
[Key(2)]
|
||||
public string StatePath { get; set; } = "";
|
||||
|
||||
[Key(3)]
|
||||
public string LastPollAtUtc { get; set; } = "";
|
||||
|
||||
[Key(4)]
|
||||
public string LastAppliedAtUtc { get; set; } = "";
|
||||
|
||||
[Key(5)]
|
||||
public int PendingBeforeApply { get; set; }
|
||||
|
||||
[Key(6)]
|
||||
public int CommandsApplied { get; set; }
|
||||
|
||||
[Key(7)]
|
||||
public int AppliedPlayerSettings { get; set; }
|
||||
|
||||
[Key(8)]
|
||||
public int AppliedLoadoutTemplates { get; set; }
|
||||
|
||||
[Key(9)]
|
||||
public int AppliedRunCheckpoints { get; set; }
|
||||
|
||||
[Key(10)]
|
||||
public int ConsecutiveFailures { get; set; }
|
||||
|
||||
[Key(11)]
|
||||
public string LastError { get; set; } = "";
|
||||
|
||||
[Key(12)]
|
||||
public string Status { get; set; } = "ok";
|
||||
}
|
||||
|
|
@ -137,6 +137,11 @@ one-shot drain without leaving the host running:
|
|||
dotnet run --project .\Economy.Server\Economy.Server.csproj -- --apply-pending-once
|
||||
```
|
||||
|
||||
The server publishes `AetheriaRuntimeCommitDrainStatus` and the
|
||||
`aetheria.operations` Eve surface after each drain attempt, so pending depth,
|
||||
applied counts, failures, and timestamps are typed state rather than console-only
|
||||
status.
|
||||
|
||||
`Aetheria.State.ApplyPending` is the smaller local operator applicator for
|
||||
queued Unity runtime commits when the server host is not being used:
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue