Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't return \0 in last journal chunk #35

Merged
merged 5 commits into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ namespace fiskaltrust.Middleware.Interface.Client.Extensions
{
public static class StreamExtensions
{
public static async IAsyncEnumerable<JournalResponse> ToAsyncEnumerable(this Stream stream)
public static async IAsyncEnumerable<JournalResponse> ToAsyncEnumerable(this Stream stream, int chunkSize)
{
var chunkSize = 4096;
var buffer = new byte[chunkSize];
while ((_ = await stream.ReadAsync(buffer, 0, buffer.Length)) > 0)
int readAmount;
while ((readAmount = await stream.ReadAsync(buffer, 0, buffer.Length)) > 0)
{
yield return new JournalResponse
{
Chunk = buffer.ToList()
Chunk = buffer.Take(readAmount).ToList()
};
buffer = new byte[chunkSize];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.3.4",
"version": "1.3.5",
TSchmiedlechner marked this conversation as resolved.
Show resolved Hide resolved
"releaseBranches": [
"^refs/heads/master$",
"^refs/tags/v\\d+(?:\\.\\d+)*(?:-.*)?$"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public AsyncJournalPOSHelper(IPOS innerPOS)
public IAsyncEnumerable<JournalResponse> JournalAsync(JournalRequest request)
{
var stream = _innerPOS.Journal(request.ftJournalType, request.From, request.To);
return stream.ToAsyncEnumerable();
return stream.ToAsyncEnumerable(request.MaxChunkSize);
}

public Task<EchoResponse> EchoAsync(EchoRequest message) => _innerPOS.EchoAsync(message);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.3.4",
"version": "1.3.5",
TSchmiedlechner marked this conversation as resolved.
Show resolved Hide resolved
"releaseBranches": [
"^refs/heads/master$",
"^refs/tags/v\\d+(?:\\.\\d+)*(?:-.*)?$"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public AsyncPOSHelper(ifPOS.v1.IPOS innerPOS)
public IAsyncEnumerable<ifPOS.v1.JournalResponse> JournalAsync(ifPOS.v1.JournalRequest request)
{
var stream = _innerPOS.Journal(request.ftJournalType, request.From, request.To);
return stream.ToAsyncEnumerable();
return stream.ToAsyncEnumerable(request.MaxChunkSize);
}

public Task<ifPOS.v1.EchoResponse> EchoAsync(ifPOS.v1.EchoRequest message) => Task.Run(() => _innerPOS.EchoAsync(message));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.3.4",
"version": "1.3.5",
TSchmiedlechner marked this conversation as resolved.
Show resolved Hide resolved
"releaseBranches": [
"^refs/heads/master$",
"^refs/tags/v\\d+(?:\\.\\d+)*(?:-.*)?$"
Expand Down