Skip to content

feat(buffer): async + collapsing buffer for awaitable batching - #54

Draft
shavounet wants to merge 2 commits into
masterfrom
feat/async-buffer
Draft

feat(buffer): async + collapsing buffer for awaitable batching#54
shavounet wants to merge 2 commits into
masterfrom
feat/async-buffer

Conversation

@shavounet

Copy link
Copy Markdown

Stale work — opening as draft to keep it visible. Needs tests + polish before it can be considered for merge.

Summary

  • Adds AsyncBuffer: register args, get a Promise back, the buffer auto-flushes on
    event-loop idle, on min/max wait time, or on size threshold. Caller-supplied flusher
    generator resolves the deferred items.
  • Adds CollapsingBuffer: thin layer over AsyncBuffer that deduplicates by key —
    duplicate registrations return the same in-flight Promise.
  • Adds UnresolvedItemsException thrown when the flusher leaves items pending.
  • Adds psr/log: ^3.0 for optional debug logging inside AsyncBuffer.

Follow-ups before merge

  • Tests for AsyncBuffer (idle/min-wait/max-wait/size triggers, exception path)
  • Tests for CollapsingBuffer key dedup
  • Add declare(strict_types=1) to CollapsingBuffer.php and UnresolvedItemsException.php
  • Type UnresolvedItemsException::getItems(): array and tighten the array<> generics

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant