Repository navigation
Expand file tree
/
Copy pathWorkflowOutputPublisher.cs
More file actions
60 lines (53 loc) · 1.67 KB
/
Copy pathWorkflowOutputPublisher.cs
File metadata and controls
60 lines (53 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
namespace BlogWriter;
internal sealed class WorkflowOutputPublisher
{
private readonly IProgress<WorkflowOutputUpdate>? _output;
private readonly long _operationVersion;
private long _sequence;
public WorkflowOutputPublisher(IProgress<WorkflowOutputUpdate>? output, long operationVersion)
{
_output = output;
_operationVersion = operationVersion;
}
public void PublishLifecycle(
WorkflowOutputOutcome outcome,
string message,
WorkflowAgentStage agentStage = WorkflowAgentStage.None)
{
Publish(WorkflowOutputKind.Lifecycle, outcome, message, revisionNumber: null, agentStage);
}
public void PublishReviewer(string message, int revisionNumber)
{
Publish(WorkflowOutputKind.ReviewerFeedback, WorkflowOutputOutcome.Review, message, revisionNumber);
}
private void Publish(
WorkflowOutputKind kind,
WorkflowOutputOutcome outcome,
string message,
int? revisionNumber,
WorkflowAgentStage agentStage = WorkflowAgentStage.None)
{
if (_output is null || string.IsNullOrWhiteSpace(message))
{
return;
}
long sequence = ++_sequence;
WorkflowOutputUpdate update = WorkflowOutputUpdate.Create(
kind,
outcome,
message,
_operationVersion,
sequence,
$"workflow-{_operationVersion}-{sequence}",
revisionNumber,
agentStage);
try
{
_output.Report(update);
}
catch
{
// Output is observational; a UI observer must not change workflow semantics.
}
}
}