Skip to content

Commit

Permalink
Merge branch 'feature/type-rendering-cleanup' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
aabs committed Aug 23, 2024
2 parents a75ed01 + 3f45479 commit 905cc17
Show file tree
Hide file tree
Showing 15 changed files with 231 additions and 154 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,5 @@ ASALocalRun/
.localhistory/

# BeatPulse healthcheck temp database
healthchecksdb
healthchecksdb
/PaxHeader
57 changes: 9 additions & 48 deletions ActorSrcGen.Playground/MyActor.cs
Original file line number Diff line number Diff line change
@@ -1,52 +1,13 @@
namespace ActorSrcGen.Abstractions.Playground;
using Gridsum.DataflowEx;
using Microsoft.Extensions.Logging;

[Actor]
public partial class MyActor
{
public List<int> Results { get; set; } = [];
public int Counter { get; set; }
namespace ActorSrcGen.Abstractions.Playground;

[FirstStep("blah")]
[Receiver]
[NextStep(nameof(DoTask2))]
[NextStep(nameof(LogMessage))]
public Task<string> DoTask1(int x)
{
Console.WriteLine("DoTask1");
public record Context<TRequestType, TPayloadType>(TRequestType OriginalRequest,
TPayloadType Data,
Stack<IDisposable> Activities);

return Task.FromResult(x.ToString());
}
public record PollRequest(string Id, string Name);

protected async partial Task<int> ReceiveDoTask1(CancellationToken ct)
{
await Task.Delay(1000, ct);

return Counter++;
}


[Step]
[NextStep(nameof(DoTask3))]
public Task<string> DoTask2(string x)
{
Console.WriteLine("DoTask2");

return Task.FromResult($"100{x}");
}

[LastStep]
public async Task<int> DoTask3(string input)
{
await Console.Out.WriteLineAsync("DoTask3");
var result = int.Parse(input);
Results.Add(result);

return result;
}

[LastStep]
public void LogMessage(string x)
{
Console.WriteLine("Incoming Message: " + x);
}
}
public record DataPoint(DateTimeOffset Timestamp, double Value);
public record TelemetryResponse(string Id, string Name, DataPoint[] Result);
74 changes: 74 additions & 0 deletions ActorSrcGen.Playground/MyPipeline.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
namespace ActorSrcGen.Abstractions.Playground;

using TResponse = Context<PollRequest, TelemetryResponse>;
using TRequest = Context<PollRequest, PollRequest>;

[Actor]
public partial class MyPipeline
{
// decode
[FirstStep("decode poll request")]
[Receiver]
[NextStep(nameof(SetupGapTracking))]
[NextStep(nameof(LogIncomingPollRequest))]
public TRequest DecodePollRequest(string x)
{
throw new NotImplementedException();
}

protected partial Task<string> ReceiveDecodePollRequest(CancellationToken ct)
{
throw new NotImplementedException();
}

[Step]
[NextStep(nameof(SplitRequestBySignal))]
public TRequest SetupGapTracking(TRequest x)
{
throw new NotImplementedException();
}

[NextStep(nameof(PollForMetrics))]
public List<TRequest> SplitRequestBySignal(TRequest input)
{
throw new NotImplementedException();
}

[Step]
[NextStep(nameof(EncodeResult))]
public TResponse PollForMetrics(TRequest x)
{
throw new NotImplementedException();
}

// encode results

[Step]
[NextStep(nameof(DeliverResults))]
public TResponse EncodeResult(TResponse x)
{
throw new NotImplementedException();
}
// deliver results

[Step]
[NextStep(nameof(TrackTelemetryGaps))]
public TResponse DeliverResults(TResponse x)
{
throw new NotImplementedException();
}
// track gaps

[LastStep]
public List<bool> TrackTelemetryGaps(TResponse x)
{
throw new NotImplementedException();
}

[LastStep]
public void LogIncomingPollRequest(TRequest x)
{
Console.WriteLine("Incoming Poll Request: " + x.OriginalRequest.Name);
}

}
2 changes: 1 addition & 1 deletion ActorSrcGen.Playground/MyWorkflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ public Task<int> DoTask3(string input)
Console.WriteLine("DoTask3");
return Task.FromResult(int.Parse(input));
}
}
}
8 changes: 5 additions & 3 deletions ActorSrcGen.Playground/Program.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
using ActorSrcGen.Abstractions.Playground;

var actor = new MyActor();
var actor = new MyPipeline();

try
{
if (actor.Call(10))
if (actor.Call("""
{ "something": "here" }
"""))
Console.WriteLine("Called Synchronously");

var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));

var t = Task.Run(async () => await actor.ListenForReceiveDoTask1(cts.Token), cts.Token);
var t = Task.Run(async () => await actor.ListenForReceiveDecodePollRequest(cts.Token), cts.Token);

while (!cts.Token.IsCancellationRequested)
{
Expand Down
2 changes: 2 additions & 0 deletions ActorSrcGen.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Gridsum/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
2 changes: 1 addition & 1 deletion ActorSrcGen/ActorSrcGen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<LangVersion>11</LangVersion>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<Description>A C# Source Generator to adapt a simple class to allow it to use TPL Dataflow for robust high performance computation</Description>
<Configurations>Debug;Release;Gen</Configurations>
Expand Down
Loading

0 comments on commit 905cc17

Please sign in to comment.