Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
firebase-simple-queue
Advanced tools
Simple queue implementation for firebase cloud functions and realtime database
Simple queue implementation for firebase cloud functions and realtime database
The queue will sequentially run each task added in the queue
If your calllback is asyncronous, make sure to await each asyncronous subtasks or async functions, otherwise the queue could not work properly
yarn add firebase-simple-queue
or using npm
npm install --save firebase-simple-queue
Initialize the queue in cloud functions index
// Import the plugin
import queue from 'firebase-simple-queue'
/* Define a callback with your custom async logic
* You callback will receve as parameter witch you have been pushed in the task
*/
function callback(task, context) {
return new Promise(resolve => {
setTimeout(() => {
// Do whatever you want.
resolve()
}, 5000)
})
}
/* Initialize the queue
* @param key A key for the realtime database tree
* @param callback The callback with your custom logic
*/
const { onCreateTask, onFinishTask, onRetryTask } = queue('somePath/{someParam}/queue', callback)
// Now register the cloud functions triggers
export {
// ...another functions
onCreateTask,
onFinishTask,
onRetryTask
}
Add an index in database.rules
{
"rules": {
"queue": {
"tasks": {
".indexOn": "_error"
}
}
}
}
Now in your client just add a task in the queue
const myTaskObject = { attr1: 'Test1', another_attr: 123 }
// Your task can be a number, string or object
database
.ref('queue')
.child('tasks')
.push(myTaskObject)
If a task throws an error, the details will be in a _error
key inside the task. To try run a task with error again, just remove the key _error
The task with the key _error
will be ignored in the execution queue. Ex: If I have 3 tasks in the queue and the first one is in error, the queue will only execute tasks 2 and 3.
Just edit the code, commit, and run ./publish.sh
You can open an issue or send a pull request
Daniel Fernando Lourusso - dflourusso@gmail.com
FAQs
Simple queue implementation for firebase cloud functions and realtime database
The npm package firebase-simple-queue receives a total of 0 weekly downloads. As such, firebase-simple-queue popularity was classified as not popular.
We found that firebase-simple-queue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.