Skip to content

Commit

Permalink
still
Browse files Browse the repository at this point in the history
  • Loading branch information
lorensr committed Mar 30, 2024
1 parent 64d8186 commit 86477ec
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/SignalsQueries/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,29 @@ async Task RunWorkerAsync()

async Task ExecuteWorkflowAsync()
{
// If the workflow is already running from a previous run, terminate it
try
{
await client.GetWorkflowHandle("signals-queries-workflow-id").TerminateAsync();
}
catch
{
// Ignore
}
await Task.CompletedTask;
// // If the workflow is already running from a previous run, terminate it
// try
// {
// await client.GetWorkflowHandle("signals-queries-workflow-id").TerminateAsync();
// }
// catch
// {
// // Ignore
// }

Console.WriteLine("Executing workflow");
var handle = await client.StartWorkflowAsync(
(LoyaltyProgram wf) => wf.RunAsync("user-id-123"),
new(id: "signals-queries-workflow-id", taskQueue: "signals-queries-sample"));
// Console.WriteLine("Executing workflow");
// var handle = await client.StartWorkflowAsync(
// (LoyaltyProgram wf) => wf.RunAsync("user-id-123"),
// new(id: "signals-queries-workflow-id", taskQueue: "signals-queries-sample"));

Console.WriteLine("Signal: Purchase made for $80");
await handle.SignalAsync(wf => wf.NotifyPurchaseAsync(new Purchase("purchase-1", 8_000)));
Console.WriteLine("Signal: Purchase made for $30");
await handle.SignalAsync(wf => wf.NotifyPurchaseAsync(new Purchase("purchase-1", 3_000)));
// Console.WriteLine("Signal: Purchase made for $80");
// await handle.SignalAsync(wf => wf.NotifyPurchaseAsync(new Purchase("purchase-1", 8_000)));
// Console.WriteLine("Signal: Purchase made for $30");
// await handle.SignalAsync(wf => wf.NotifyPurchaseAsync(new Purchase("purchase-1", 3_000)));

var points = await handle.QueryAsync(wf => wf.Points);
Console.WriteLine("Remaining points: {0}", points);
// var points = await handle.QueryAsync(wf => wf.Points);
// Console.WriteLine("Remaining points: {0}", points);
}

switch (args.ElementAtOrDefault(0))
Expand Down

0 comments on commit 86477ec

Please sign in to comment.