NAME
PAGI::FastAPI::Queue::Driver - Abstract Base Class for Message Queue Storage Drivers
VERSION
Version v1.1.0
SYNOPSIS
package PAGI::FastAPI::Queue::Driver::Custom;
use v5.38;
use experimental 'class';
use Future::AsyncAwait;
use PAGI::FastAPI::Queue::Driver;
class PAGI::FastAPI::Queue::Driver::Custom
:isa(PAGI::FastAPI::Queue::Driver) {
async method push ($topic, $payload) {
# Enqueue $payload onto $topic asynchronously...
return 1;
}
async method pop ($topic) {
# Dequeue and return the next item for $topic asynchronously...
return $item;
}
async method size ($topic = undef) {
# Report pending item count asynchronously...
return $count;
}
}
DESCRIPTION
PAGI::FastAPI::Queue::Driver creates the asynchronous abstract interface used for all message queue backends by PAGI::FastAPI::Queue.
Any new storage drivers (like Redis, SQS, or a queue based on a database) should use this class as a superclass and code the asynchronous methods in it to ensure these methods result in the creation of L instances and consequently, will not block the event loop of PAGI.
As of version v1.1.0, we have built-in support for in memory message queue by +PAGI::FastAPI::Queue::Driver::Memory. + +We even have demo app created for in memory rate limit: eg/memory_queue_demo.pl + +If you are looking for more specialised options then you have another choice as a separate companion package: PAGI::FastAPI::Queue::Driver::Redis.
REQUIRED METHODS
Subclasses must override the following methods. Calling any of these directly on the base class returns a failed Future.
push($topic, $payload)
my $future = $driver->push($topic, $payload);
Enqueues $payload (any scalar) onto $topic. Returns a Future resolving to a true value on success.
pop($topic)
my $future = $driver->pop($topic);
Dequeues and returns a Future resolving to the next pending item for $topic, or undef if $topic is empty or unknown.
size($topic = undef)
my $future = $driver->size($topic);
Returns a Future resolving to the integer count of pending items in $topic. If $topic is omitted (or undef), should resolve to the total pending item count across all topics.
SEE ALSO
PAGI::FastAPI::Queue::Driver::Memory, PAGI::FastAPI::Queue
AUTHOR
Mohammad Sajid Anwar, <mohammad.anwar at yahoo.com>
REPOSITORY
https://github.com/manwar/PAGI-FastAPI
BUGS
Please report any bugs or feature requests through the web interface at https://github.com/manwar/PAGI-FastAPI/issues. I will be notified and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc PAGI::FastAPI::Queue::Driver
You can also look for information at:
BUG Report
CPAN Ratings
Search MetaCPAN
LICENSE AND COPYRIGHT
Copyright (C) 2026 Mohammad Sajid Anwar.
This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License (2.0).