Skip to content

Commit

Permalink
Poll in batches of no more than 100 tags (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
wazzamatazz committed Aug 28, 2023
1 parent 551ff31 commit cf65bcf
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/DataCore.Adapter/RealTimeData/PollingSnapshotTagValuePush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,30 @@ public class PollingSnapshotTagValuePush : SnapshotTagValuePush {
return;
}

await foreach (var val in _readSnapshotFeature.ReadSnapshotTagValues(
new DefaultAdapterCallContext(),
new ReadSnapshotTagValuesRequest() {
Tags = tags
}, cancellationToken
).ConfigureAwait(false)) {
if (val == null) {
continue;
const int MaxTagsPerRequest = 100;
var page = 0;
var @continue = false;

do {
++page;
var pageTags = tags.Skip((page - 1) * MaxTagsPerRequest).Take(MaxTagsPerRequest).ToArray();
if (pageTags.Length == 0) {
break;
}
await ValueReceived(val, cancellationToken).ConfigureAwait(false);
}
@continue = pageTags.Length == MaxTagsPerRequest;

await foreach (var val in _readSnapshotFeature.ReadSnapshotTagValues(
new DefaultAdapterCallContext(),
new ReadSnapshotTagValuesRequest() {
Tags = tags
}, cancellationToken
).ConfigureAwait(false)) {
if (val == null) {
continue;
}
await ValueReceived(val, cancellationToken).ConfigureAwait(false);
}
} while (@continue);
}


Expand Down

0 comments on commit cf65bcf

Please sign in to comment.