Skip to content

Commit

Permalink
Merge pull request #176 from fiskaltrust/fix-journal-error-handling
Browse files Browse the repository at this point in the history
return error if journal fails instead of waiting forever
  • Loading branch information
volllly authored Sep 20, 2024
2 parents b8ee2b0 + 35b8cf2 commit ca888cf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines/templates/stages/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ stages:
scriptFolder: 'linux'

osx-x64:
vmImage: macos-11
vmImage: macos-latest
target: osx-x64
scriptFolder: 'macos'

Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines/templates/stages/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ stages:

- job: TestMacOS
pool:
vmImage: macos-11
vmImage: macos-latest

steps:
- template: ../restore.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ public static WebApplication AddQueueEndpoints(this WebApplication app, IPOS pos
app.MapMultiplePrefixed(_prefixesV1, "Echo", EndpointRouteBuilderExtensions.MapPost, async (ifPOS.v1.EchoRequest req) => await pos.EchoAsync(req));
app.MapMultiplePrefixed(_prefixesV0, "Echo", EndpointRouteBuilderExtensions.MapPost, async ([FromBody] string message) => (await pos.EchoAsync(new ifPOS.v1.EchoRequest { Message = message })).Message);
app.MapMultiplePrefixed(_prefixes, "Sign", EndpointRouteBuilderExtensions.MapPost, async (ReceiptRequest req) => await pos.SignAsync(req));
app.MapMultiplePrefixed(_prefixes, "Journal", EndpointRouteBuilderExtensions.MapPost, ([FromQuery] long type, [FromQuery] long? from, [FromQuery] long? to) =>
app.MapMultiplePrefixed(_prefixes, "Journal", EndpointRouteBuilderExtensions.MapPost, async ([FromQuery] long type, [FromQuery] long? from, [FromQuery] long? to) =>
{
var pipe = new Pipe();
var journal = pos.JournalAsync(new JournalRequest { ftJournalType = type, From = from ?? 0, To = to ?? 0 });
// Throws if something failed in the request. Does not pop the first element
await journal.FirstAsync();
var _ = Task.Run(async () =>
{
await journal.ForEachAwaitAsync(async b => await pipe.Writer.WriteAsync(new ReadOnlyMemory<byte>(b.Chunk.ToArray())));
Expand Down

0 comments on commit ca888cf

Please sign in to comment.