Skip to content

Commit

Permalink
Re-structured checkpoint execution. modified release yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
juanpgarces committed Jan 26, 2021
1 parent 4ba2429 commit f5b9212
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 70 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ jobs:
with:
nuget-version: 'latest'
- name: Restore packages
run: nuget restore src\UPS.sln
run: nuget restore src\UPS.csproj
- name: .NET Build
run: dotnet build src\UPS.sln --configuration Release
- name: Create the package
run: dotnet publish --configuration Release src\UPS.sln
run: dotnet publish --configuration Release src\UPS.csproj
- name: Publish to NuGet
uses: brandedoutcast/publish-nuget@v2
with:
PROJECT_FILE_PATH: src\UPS.csproj
VERSION_REGEX: '^\s*<PackageVersion>(.*)<\/PackageVersion>\s*$'
TAG_FORMAT: '*'
NUGET_KEY: ${{secrets.NUGET_API_KEY}}

44 changes: 10 additions & 34 deletions src/UPS/FuncMultipleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,15 @@ await Task.Factory.StartNew(async () =>
while (!queue.IsEmpty)
{
queue.TryPeek(out ReferencedFunc<object> referencedTask);
if (referencedTask != null && referencedTask.checkpoint != null)
if (referencedTask != null)
{
// Find a better way to wait until checkpoint is true
if (await referencedTask.checkpoint.Invoke() == true)
// Accounts for Tasks Not specifying a non-required Checkpoint
if (referencedTask.checkpoint == null)
{
if (queue.TryDequeue(out ReferencedFunc<object> dequeuedReferencedTask))
await ExecuteAsync(dequeuedReferencedTask);
}
else if(await (referencedTask.checkpoint?.Invoke()) == true)
{
if (queue.TryDequeue(out ReferencedFunc<object> dequeuedReferencedTask))
await ExecuteAsync(dequeuedReferencedTask);
Expand All @@ -126,7 +131,7 @@ await Task.Factory.StartNew(async () =>
break;
}
}
else if (referencedTask == null)
else
{
queue.TryDequeue(out referencedTask);
}
Expand All @@ -139,36 +144,7 @@ await Task.Factory.StartNew(async () =>

private static async Task ExecuteAsync(ReferencedFunc<object> referencedTask)
{
object result = null;

result = await (referencedTask?.func?.Invoke());

//try
//{
// result = await referencedTask.func.Invoke();
//}
//catch (Exception ex)
//{
// // After trying the maximun number of attemtps, Enqueue to lower tier
// if (referencedTask.currentAttempt <= maxFailedAttempts)
// {
// referencedTask.currentAttempt++;
// await ExecuteAsync(referencedTask);
// }
// else
// {
// //referencedTask.priority++;
// //if (referencedTask.priority <= maxQueues)
// //{
// // EnqueueReferencedFunc(referencedTask);
// //}
// //else
// //{
// // //AddReferencedException(new ReferencedException() { guid = referencedTask.guid, exception = ex });
// //}
// }
//}
//AddReferencedResult(new ReferencedResult() { guid = referencedTask.guid, result = result });
await (referencedTask?.func?.Invoke());
}

//private static void AddReferencedResult(ReferencedResult referencedResult)
Expand Down
45 changes: 12 additions & 33 deletions src/UPS/FuncPriorityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,25 @@ await Task.Factory.StartNew(async () =>
while (!queue.IsEmpty)
{
queue.TryPeek(out ReferencedFunc<object> referencedTask);
if (referencedTask != null && referencedTask.checkpoint != null)
if (referencedTask != null)
{
// Find a better way to wait until checkpoint is true
if (await referencedTask.checkpoint.Invoke() == true)
// Accounts for Tasks Not specifying a non-required Checkpoint
if (referencedTask.checkpoint == null)
{
if (queue.TryDequeue(out ReferencedFunc<object> dequeuedReferencedTask))
await ExecuteAsync(dequeuedReferencedTask);
}
else if(await (referencedTask.checkpoint?.Invoke()) == true)
{
if (queue.TryDequeue(out ReferencedFunc<object> dequeuedReferencedTask))
await ExecuteAsync(dequeuedReferencedTask);
}
else
{
break;
}
}
else if (referencedTask == null)
else
{
queue.TryDequeue(out referencedTask);
}
Expand All @@ -175,35 +180,9 @@ await Task.Factory.StartNew(async () =>
}

private static async Task ExecuteAsync(ReferencedFunc<object> referencedTask)
{
object result = null;

try
{
result = await (referencedTask?.func?.Invoke());
}
catch (Exception ex)
{
// After trying the maximun number of attemtps, Enqueue to lower tier
//if (referencedTask.currentAttempt <= maxFailedAttempts)
//{
// referencedTask.currentAttempt++;
//await ExecuteAsync(referencedTask);
////}
////else
////{
//referencedTask.priority++;
//if (referencedTask.priority <= maxQueues)
//{
// EnqueueReferencedFunc(referencedTask);
//}
//else
//{
AddReferencedException(new ReferencedException() { guid = referencedTask.guid, exception = ex });
//}
//}
}
AddReferencedResult(new ReferencedResult() { guid = referencedTask.guid, result = result });
{
await (referencedTask?.func?.Invoke());
//AddReferencedResult(new ReferencedResult() { guid = referencedTask.guid, result = result });
}

private static void AddReferencedResult(ReferencedResult referencedResult)
Expand Down
2 changes: 1 addition & 1 deletion src/UPS/UPS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<RepositoryUrl>https://github.com/juanp3053/UPS</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<Description>Asynchronous and Resiliiant library to execute Functions safely</Description>
<Version>0.0.11</Version>
<Version>0.0.12</Version>
<AssemblyVersion>$(Version)</AssemblyVersion>
<FileVersion>$(Version)</FileVersion>
<PackageId>juanp3053.FuncManager</PackageId>
Expand Down

0 comments on commit f5b9212

Please sign in to comment.