FeedInterface.php
3 weeks ago
FeedLockException.php
5 days ago
FeedValidatorInterface.php
5 months ago
ProductLoader.php
5 months ago
ProductMapperInterface.php
5 days ago
ProductWalker.php
5 days ago
ResumableFeedInterface.php
5 days ago
WalkerProgress.php
5 months ago
ResumableFeedInterface.php
72 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Resumable Feed Interface. |
| 4 | * |
| 5 | * @package Automattic\WooCommerce\Internal\ProductFeed |
| 6 | */ |
| 7 | |
| 8 | declare(strict_types=1); |
| 9 | |
| 10 | namespace Automattic\WooCommerce\Internal\ProductFeed\Feed; |
| 11 | |
| 12 | /** |
| 13 | * Contract for feeds that can be written across multiple processes (chunked generation). |
| 14 | * |
| 15 | * This is deliberately kept separate from {@see FeedInterface}: a feed backend opts into chunked, |
| 16 | * resumable generation by implementing this interface *in addition to* FeedInterface. Existing |
| 17 | * FeedInterface implementations (including those provided by third-party integrations) remain |
| 18 | * valid and are unaffected, so adding this contract is a backwards-compatible change. |
| 19 | * |
| 20 | * @since 11.0.0 |
| 21 | */ |
| 22 | interface ResumableFeedInterface extends FeedInterface { |
| 23 | /** |
| 24 | * Start a feed fresh, or resume one that a previous chunk began. |
| 25 | * |
| 26 | * A feed may be written across separate processes (one Action Scheduler action per chunk), so it |
| 27 | * lives in a stable, shared location identified by the returned value. Pass that identifier back on |
| 28 | * a later chunk to keep appending to the same feed; pass nothing to begin a new one. |
| 29 | * |
| 30 | * @since 11.0.0 |
| 31 | * |
| 32 | * @param string|null $resume_identifier Identifier of an existing feed to resume, or null to start fresh. |
| 33 | * @param int $entries_written The number of entries already written by previous chunks, so |
| 34 | * separators are added correctly when resuming. |
| 35 | * @return string The identifier of the feed that was started, to be passed back by later chunks. |
| 36 | */ |
| 37 | public function open( ?string $resume_identifier = null, int $entries_written = 0 ): string; |
| 38 | |
| 39 | /** |
| 40 | * Persist the current chunk and release the file handle without finalizing the feed. |
| 41 | * |
| 42 | * Called at the end of a chunk that is not the last one, so a later chunk can resume. |
| 43 | * |
| 44 | * @since 11.0.0 |
| 45 | * |
| 46 | * @return void |
| 47 | */ |
| 48 | public function flush(): void; |
| 49 | |
| 50 | /** |
| 51 | * Delete a feed (e.g. a partial feed left by an abandoned chunked generation). |
| 52 | * |
| 53 | * @since 11.0.0 |
| 54 | * |
| 55 | * @param string $identifier The identifier returned by {@see open()}. |
| 56 | * @return void |
| 57 | */ |
| 58 | public function delete( string $identifier ): void; |
| 59 | |
| 60 | /** |
| 61 | * Get the number of entries that have been written to the feed. |
| 62 | * |
| 63 | * This reflects the rows actually written, which may be fewer than the number of products |
| 64 | * iterated, because the validator can silently drop entries before they are added. |
| 65 | * |
| 66 | * @since 11.0.0 |
| 67 | * |
| 68 | * @return int Number of entries written to the feed. |
| 69 | */ |
| 70 | public function get_entry_count(): int; |
| 71 | } |
| 72 |