feat: expose mapped raw and uns data through grpc adapters
This commit is contained in:
@@ -67,7 +67,7 @@ public sealed record ScriptRunnerStatus(
|
||||
/// HMAC-verified compiled images instead of re-entering Roslyn after a restart.</item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
public sealed class OutOfProcessScriptRunner : IScriptRunner, IAsyncDisposable, IDisposable
|
||||
public sealed class OutOfProcessScriptRunner : IPhysicalScriptRunner, IAsyncDisposable, IDisposable
|
||||
{
|
||||
/// <summary>The worker entry assembly's file name.</summary>
|
||||
public const string WorkerAssemblyFileName = "ZB.MOM.WW.OtOpcUa.ScriptWorker.dll";
|
||||
@@ -366,6 +366,13 @@ public sealed class OutOfProcessScriptRunner : IScriptRunner, IAsyncDisposable,
|
||||
public async Task<ScriptRunOutcome> RunAsync(ScriptInvocation invocation, CancellationToken ct = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(invocation);
|
||||
var ownership = new PhysicalLeaseOwnership(invocation.PhysicalLease);
|
||||
try { return await RunOwnedAsync(invocation, ownership, ct).ConfigureAwait(false); }
|
||||
finally { ownership.DisposeIfUntransferred(); }
|
||||
}
|
||||
|
||||
private async Task<ScriptRunOutcome> RunOwnedAsync(ScriptInvocation invocation, PhysicalLeaseOwnership ownership, CancellationToken ct)
|
||||
{
|
||||
if (Volatile.Read(ref _disposed) != 0) return ScriptRunOutcome.Unavailable(ScriptRunOutcome.RunnerUnavailableReason);
|
||||
|
||||
var key = InProcessScriptRunner.ScopedKey(invocation.Kind, invocation.Key);
|
||||
@@ -435,7 +442,8 @@ public sealed class OutOfProcessScriptRunner : IScriptRunner, IAsyncDisposable,
|
||||
// run by then.
|
||||
var submitted = Stopwatch.GetTimestamp();
|
||||
var pending = connection.Submit(key, BuildRequest(key, entry, invocation), invocation.Timeout,
|
||||
_worker.EffectiveHardGrace(invocation.Timeout), SlotRelease(key, state, gate));
|
||||
_worker.EffectiveHardGrace(invocation.Timeout), SlotRelease(key, state, gate, ownership));
|
||||
ownership.Transfer();
|
||||
handedOff = true;
|
||||
return await AwaitSubmittedAsync(key, state, invocation, shard, connection, pending, submitted, ct).ConfigureAwait(false);
|
||||
}
|
||||
@@ -478,6 +486,7 @@ public sealed class OutOfProcessScriptRunner : IScriptRunner, IAsyncDisposable,
|
||||
{
|
||||
var invocation = invocations[i];
|
||||
ArgumentNullException.ThrowIfNull(invocation);
|
||||
if (invocation.PhysicalLease is not null) { outcomes[i] = RunAsync(invocation, ct); continue; }
|
||||
switch (TryPrepareBatchItem(invocation, out var item, out var answered))
|
||||
{
|
||||
case BatchPreparation.Submit:
|
||||
@@ -555,16 +564,20 @@ public sealed class OutOfProcessScriptRunner : IScriptRunner, IAsyncDisposable,
|
||||
/// 32 of 200 refused when the release was an unordered continuation). On a worker death, attribution (strike,
|
||||
/// quarantine, suspect) has already run by then.
|
||||
/// </summary>
|
||||
private Action SlotRelease(string key, KeyState state, SemaphoreSlim? heldGate)
|
||||
private Action SlotRelease(string key, KeyState state, SemaphoreSlim? heldGate, IDisposable? physicalLease = null)
|
||||
{
|
||||
var released = 0;
|
||||
return () =>
|
||||
{
|
||||
if (Interlocked.Exchange(ref released, 1) != 0) return;
|
||||
SlotReleasingForTest?.Invoke(key);
|
||||
Volatile.Write(ref state.StalledRun, null);
|
||||
Interlocked.Exchange(ref state.InFlight, 0);
|
||||
heldGate?.Release();
|
||||
try
|
||||
{
|
||||
SlotReleasingForTest?.Invoke(key);
|
||||
Volatile.Write(ref state.StalledRun, null);
|
||||
Interlocked.Exchange(ref state.InFlight, 0);
|
||||
heldGate?.Release();
|
||||
}
|
||||
finally { physicalLease?.Dispose(); }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user