Server-side scenario execution: effects client replaces local engine
- client.Effects: typed effects + completion methods posting scenario callbacks - client.Scenario reduced to TriggerAsync - pending polling via Update() pump: 30s heartbeat + wait-deadline checks - local engine, plan persistence (IPlanStateStore) and resume removed - RealtimeService and realtime transports removed (relay never deployed) - dead IPlanScheduler leftover removed - models regenerated from openapi (ExecutionPlan/BoundaryNode gone, PendingEffect added)
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace RudderSdk.Core;
|
||||
|
||||
/// <summary>
|
||||
/// A scenario quest node. Report objective progress; the server auto-completes
|
||||
/// the node once every objective is satisfied.
|
||||
/// </summary>
|
||||
public sealed class QuestEffect
|
||||
{
|
||||
private readonly EffectHandle _handle;
|
||||
|
||||
internal QuestEffect(EffectHandle handle) => _handle = handle;
|
||||
|
||||
/// <summary>Run id.</summary>
|
||||
public string RunId => _handle.RunId;
|
||||
|
||||
/// <summary>Scenario id.</summary>
|
||||
public string ScenarioId => _handle.ScenarioId;
|
||||
|
||||
/// <summary>Node id.</summary>
|
||||
public string NodeId => _handle.NodeId;
|
||||
|
||||
/// <summary>Quest name from the node data.</summary>
|
||||
public string Name => _handle.Get("name", string.Empty);
|
||||
|
||||
/// <summary>Objective definitions from the node data.</summary>
|
||||
public IReadOnlyList<JObject> Objectives
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_handle.Data["objectives"] is not JArray array)
|
||||
return Array.Empty<JObject>();
|
||||
|
||||
var list = new List<JObject>(array.Count);
|
||||
foreach (var item in array)
|
||||
{
|
||||
if (item is JObject obj)
|
||||
list.Add(obj);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Node data payload.</summary>
|
||||
public JObject Data => _handle.Data;
|
||||
|
||||
/// <summary>Reads a typed value from the node data.</summary>
|
||||
public T Get<T>(string key, T defaultValue = default!) => _handle.Get(key, defaultValue);
|
||||
|
||||
/// <summary>Reports progress toward an objective via <c>POST /sdk/v1/scenarios/counter</c>.</summary>
|
||||
public Task ReportProgressAsync(string objectiveId, long amount = 1, CancellationToken cancellationToken = default)
|
||||
=> _handle.ReportProgressAsync(objectiveId, amount, cancellationToken);
|
||||
|
||||
/// <summary>Reports progress toward an objective (fire-and-forget).</summary>
|
||||
public void ReportProgress(string objectiveId, long amount = 1) => _handle.ReportProgress(objectiveId, amount);
|
||||
}
|
||||
Reference in New Issue
Block a user