Skip to content

Commit d191c29

Browse files
feat(client): add streaming
1 parent b3eab16 commit d191c29

File tree

3 files changed

+21
-109
lines changed

3 files changed

+21
-109
lines changed

src/Core/Adapters/GeneratorStream.php

Lines changed: 0 additions & 107 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Scrapegraphai\Core\Contracts;
6+
7+
/**
8+
* @template TInner
9+
*
10+
* @extends \IteratorAggregate<int,TInner>
11+
*/
12+
interface CloseableStream extends \IteratorAggregate
13+
{
14+
/**
15+
* Manually force the stream to close early.
16+
* Iterating through will automatically close as well.
17+
*/
18+
public function close(): void;
19+
}

src/Core/Util.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,13 @@ public static function decodeLines(\Iterator $stream): \Iterator
265265
/**
266266
* @param \Iterator<string> $lines
267267
*
268-
* @return \Iterator<
268+
* @return \Generator<
269269
* array{
270270
* event?: null|string, data?: null|string, id?: null|string, retry?: null|int
271271
* },
272272
* >
273273
*/
274-
public static function decodeSSE(\Iterator $lines): \Iterator
274+
public static function decodeSSE(\Iterator $lines): \Generator
275275
{
276276
$blank = ['event' => null, 'data' => null, 'id' => null, 'retry' => null];
277277
$acc = [];

0 commit comments

Comments
 (0)