Skip to content

Commit f6dba99

Browse files
authored
Merge pull request #114 from datalust/KodrAus-patch-1
Update the events snippet
2 parents 744cfbe + bb7c761 commit f6dba99

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

README.md

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,37 +49,15 @@ See the [signal-copy app](https://github.com/datalust/seq-api/blob/main/example/
4949

5050
Seq internally limits the resources a query is allowed to consume. The query methods on `SeqConnection.Events` include a _status_ with each result set - a `Partial` status indicates that further results must be retrieved.
5151

52-
The snippet below demonstrates paging through results to retrieve the complete set.
52+
The snippet below demonstrates lazily enumerating through results to retrieve the complete set.
5353

5454
```csharp
55-
string lastReadEventId = null;
56-
57-
while(true)
58-
{
59-
var resultSet = await connection.Events.InSignalAsync(
60-
filter: "Environment = 'Test'",
61-
render: true,
62-
afterId: lastReadEventId);
63-
64-
foreach (var evt in resultSet.Events)
65-
Console.WriteLine(evt.RenderedMessage);
66-
67-
if (resultSet.Statistics.Status == ResultSetStatus.Complete)
68-
break;
69-
70-
lastReadEventId = resultSet.Statistics.LastReadEventId;
71-
}
72-
```
73-
74-
If the result set is expected to be small, `ListAsync()` will buffer results and return a complete list:
75-
76-
```csharp
77-
var resultSet = await connection.Events.ListAsync(
55+
var resultSet = await connection.Events.EnumerateAsync(
7856
filter: "Environment = 'Test'",
7957
render: true,
8058
count: 1000);
81-
82-
foreach (var evt in resultSet)
59+
60+
await foreach (var evt in resultSet)
8361
Console.WriteLine(evt.RenderedMessage);
8462
```
8563

0 commit comments

Comments
 (0)