1.0.1-beta.10 • Published 11 months ago

sql-queue v1.0.1-beta.10

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

sql-queue

Execute and track asynchronous functions with sql-queue.

It uses sqlite database to track wether or not function was successfuly executed.

\ Currently there are 3 states:

  • Failed: -1
  • In progress: 0
  • Finished: 1 (successful)

\ Usage example\ First we need to import and instantiate Queue.

const { Queue } = require('sql-queue')

queue = new Queue('./db.db')

Now we can add a task to queue:\ It takes several parameters:

  • execFuntion - function that needs to be executed asynchronously (required)
  • args[] - array of arguments that function takes (optional)
  • info - information about task (optional)
    var taskId = await queue.add(function delayFunction(delayTime){
        return new Promise(r => setTimeout(r, delayTime));
        console.log("task 10 finish")
    }, [10000], "task#10")
    

This is a simple delay function which takes delayTime as argument.\ After we execute said code "taskId" will be equal to id assigned to task in database. It will not wait for function to finish executing but when when the task is done the database will be updated with appropriate status.

\ You can also get specific task with id:

    var id = await queue.getById(id)

Get all Tasks:

    var id = await queue.getAll()

Clear all rows in database:

    var id = await queue.clear()
1.0.1-beta.10

11 months ago

1.0.1-beta.9

11 months ago

1.0.1-beta.8

11 months ago

1.0.1-beta.7

11 months ago

1.0.1-beta.6

11 months ago

1.0.1-beta.5

11 months ago

1.0.1-beta.4

11 months ago

1.0.1-beta.3

11 months ago

1.0.1-beta.2

11 months ago

1.0.1-beta.1

11 months ago

1.0.1-beta.0

11 months ago

1.0.0-beta.0

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago