Skip to content

feat(storage): add ListableQueueStorage interface and getPending() - #8

Merged
usernane merged 3 commits into
mainfrom
dev
Aug 2, 2026
Merged

feat(storage): add ListableQueueStorage interface and getPending()#8
usernane merged 3 commits into
mainfrom
dev

Conversation

@usernane

@usernane usernane commented Aug 2, 2026

Copy link
Copy Markdown
Member

Summary

Add a ListableQueueStorage sub-interface and getPending() method to enable listing all pending jobs for admin dashboards and inspection tooling.

Motivation

The QueueStorage interface only exposes getPendingCount() which returns an integer. There is no way to retrieve the actual list of pending/scheduled jobs without directly accessing the storage internals. This makes it impossible to build admin dashboards that display queued jobs without coupling to a specific storage implementation. Fixes #7.

Changes

  • Created ListableQueueStorage interface extending QueueStorage with getPending(): QueuedJob[]
  • FileQueueStorage now implements ListableQueueStorage with sorted results (priority desc, createdAt asc)
  • Queue::getPending() delegates to storage; throws LogicException if backend does not implement ListableQueueStorage
  • QueueFacade::getPending() exposes the static API
  • Added 7 new tests covering all behaviors
  • Updated README with API docs and usage example
  • Updated examples/01-basic-queue.php with getPending() demonstration

How to Test / Verify

Unit tests:

composer test

All 33 tests pass with 72 assertions.

Breaking Changes and Migration Steps

None. ListableQueueStorage extends QueueStorage — existing custom implementations of QueueStorage continue to work unchanged. They only need to implement ListableQueueStorage if they want to support getPending().

Checklist

  • I reviewed my own diff before requesting review
  • My commits follow Conventional Commits
  • I added/updated tests (or explained why not)
  • I updated docs (if needed) Docs Repo
  • I ran lint/cs-fixer (if applicable) (composer fix-cs)
  • I considered backward compatibility
  • I considered security

Related issues

Closes #7

Ibrahim BinAlshikh added 3 commits August 2, 2026 23:51
Add .gitattributes with eol=lf and renormalize all files.
This silences CRLF warnings and standardizes the repo.
…thod

Introduce ListableQueueStorage as a sub-interface of QueueStorage for
backends that support listing pending jobs (files, database, Redis).
Backends that only support push/pop semantics (SQS, RabbitMQ) implement
the base QueueStorage interface.

- Create ListableQueueStorage interface with getPending(): QueuedJob[]
- FileQueueStorage now implements ListableQueueStorage
- Queue::getPending() delegates to storage, throws LogicException if
  backend does not implement ListableQueueStorage
- QueueFacade::getPending() exposes the static API
- Add 7 tests covering listing, sorting, non-removal, and error case
- Update README and examples with getPending() usage

Closes #7
@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.42857% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.03%. Comparing base (21cfcf0) to head (81b4330).

Files with missing lines Patch % Lines
WebFiori/Queue/FileQueueStorage.php 95.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main       #8      +/-   ##
============================================
+ Coverage     95.98%   96.03%   +0.04%     
- Complexity       71       78       +7     
============================================
  Files             4        4              
  Lines           224      252      +28     
============================================
+ Hits            215      242      +27     
- Misses            9       10       +1     
Flag Coverage Δ
php-8.1 96.03% <96.42%> (+0.04%) ⬆️
php-8.2 96.03% <96.42%> (+0.04%) ⬆️
php-8.3 96.03% <96.42%> (+0.04%) ⬆️
php-8.4 96.03% <96.42%> (+0.04%) ⬆️
php-8.5 96.03% <96.42%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@usernane
usernane merged commit f85698e into main Aug 2, 2026
16 of 18 checks passed
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.

feat(storage): add getPending() method to QueueStorage interface and implementations

1 participant