All Projects → atayahmet → Storage Based Queue

atayahmet / Storage Based Queue

Licence: mit
Javascript queue library with persistent storage based queue mechanism for the browsers environments. Specially designed for offline.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Storage Based Queue

Dianoia-app
Mobile (Ionic 3 - Angular 4) app about non-pharmaceutical activities and information for people with dementia.
Stars: ✭ 13 (-60.61%)
Mutual labels:  cordova, ionic, offline-first
Offline Plugin
Offline plugin (ServiceWorker, AppCache) for webpack (https://webpack.js.org/)
Stars: ✭ 4,444 (+13366.67%)
Mutual labels:  storage, offline-first, offline
ionic-resource-generator
Painless, Offline First, No Dependency, Ionic resources generator
Stars: ✭ 31 (-6.06%)
Mutual labels:  cordova, ionic, offline
Message Bus
Go simple async message bus
Stars: ✭ 166 (+403.03%)
Mutual labels:  async, queue, message-queue
todo-list
TodoList using Ionic2/3 & Firebase: * PWA * SSO Google plus. * Share list via QRcode. * Upload image from Camera or Storage. * Speech Recognition.
Stars: ✭ 18 (-45.45%)
Mutual labels:  cordova, ionic, storage
Nsq
A realtime distributed messaging platform (forked from https://github.com/nsqio/nsq)
Stars: ✭ 476 (+1342.42%)
Mutual labels:  queue, message-queue
Upup
✈️ Easily create sites that work offline as well as online
Stars: ✭ 4,777 (+14375.76%)
Mutual labels:  offline-first, offline
Siberite
Siberite is a simple, lightweight, leveldb backed message queue written in Go.
Stars: ✭ 583 (+1666.67%)
Mutual labels:  queue, message-queue
Capacitor
Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
Stars: ✭ 6,598 (+19893.94%)
Mutual labels:  cordova, ionic
Localforage
💾 Offline storage, improved. Wraps IndexedDB, WebSQL, or localStorage using a simple but powerful API.
Stars: ✭ 19,840 (+60021.21%)
Mutual labels:  storage, offline
Cordova Background Geolocation Lt
The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
Stars: ✭ 600 (+1718.18%)
Mutual labels:  cordova, ionic
Generator M Ionic
Advanced workflows and setup for building rock-solid Ionic apps
Stars: ✭ 677 (+1951.52%)
Mutual labels:  cordova, ionic
Cordova Plugin Ionic Webview
Web View plugin for Cordova, specialized for Ionic apps.
Stars: ✭ 419 (+1169.7%)
Mutual labels:  cordova, ionic
Taskq
Golang asynchronous task/job queue with Redis, SQS, IronMQ, and in-memory backends
Stars: ✭ 555 (+1581.82%)
Mutual labels:  queue, message-queue
Nsq
A realtime distributed messaging platform
Stars: ✭ 20,663 (+62515.15%)
Mutual labels:  queue, message-queue
Sw Precache
Service Worker Precache is a module for generating a service worker that precaches resources. It integrates with your build process. Once configured, it detects all your static resources (HTML, JavaScript, CSS, images, etc.) and generates a hash of each file's contents. Information about each file's URL and versioned hash are stored in the generated service worker file, along with logic to serve those files cache-first, and automatically keep those files up to date when changes are detected in subsequent builds.
Stars: ✭ 5,276 (+15887.88%)
Mutual labels:  offline-first, offline
Awesome Ionic
An "awesome" list of Ionic resources
Stars: ✭ 799 (+2321.21%)
Mutual labels:  cordova, ionic
Arq
Fast job queuing and RPC in python with asyncio and redis.
Stars: ✭ 695 (+2006.06%)
Mutual labels:  async, queue
Dexie.js
A Minimalistic Wrapper for IndexedDB
Stars: ✭ 7,337 (+22133.33%)
Mutual labels:  storage, offline
Fennel
A task queue library for Python and Redis
Stars: ✭ 24 (-27.27%)
Mutual labels:  async, queue

npm version Build Status Coverage Status Dependency Status devDependencies Status Known Vulnerabilities GitHub license GitHub issues

Persistent Queue For Browsers

Introduction

Storage based queue processing mechanism. Today, many backend technology is a simple derivative of the queuing systems used in the browser environment.

You can run jobs over the channels as asynchronous that saved regularly.

This library just a solution method for some use cases. Today, there are different technologies that fulfill the similar process.

Reminders:

  • Designed for only browser environments.
  • Built-in error handling.
  • ES6/ES7 features.
  • Full control over the workers.
  • React Native support. (require few minor config)
  • Native browser worker. (with polyfill)

How it works?

Data regularly store (localstorage, inmemory or custom storage drivers) added to queue pool. Storing queue data is also inspired by the JSON-RPC method. When the queue is started, the queues start to be processed sequentially in the specified range according to the sorting algorithm.

If any exceptions occur while the worker classes are processing, the current queue is reprocessed to try again. The task is frozen when it reaches the defined retry value.

Channels

You need to create at least one channel. One channel can be created as many channels as desired. Channels run independently of each other. The areas where each channel will store tasks are also separate. The area where tasks are stored is named with the channel name and prefix.

The important thing to remember here is that each newly created channel is actually a new copy of the Queue class. So a new instance is formed, but the dependencies of the channels are still alive as singletons.

Example; You created two channels. Their names are channelA and channelB. If you make a setting in the channelA instance, this change will also be reflected in channelB and all other channels.

Workers

You can create countless worker. Worker classes should return boolean (true / false) data with the Promise class as the return value. The return Promise / resolve (true) must be true if a task is successfully completed and you want to pass the next task. A possible exception should also be tried again: Promise / resolve (false). If we do not want the task to be retried and we want to pass the next task: Promise / reject ('any value')

Also you can use native browser worker. If you are browser does not support Worker, Browser Worker polyfil will add a pseudo-worker function to window object.

Plase check the docs: Workers

Installation

$ npm install storage-based-queue --save

import:

import Queue from "storage-based-queue";

Script Tag:

<script src="https://unpkg.com/[email protected]/dist/queue.min.js" />

Basic Usage

Worker class:

class MessageSenderWorker {
  handle(message) {
    // If return value is false, this task will retry until retry value 5.
    // If retry value is 5 in worker, current task will be as failed and freezed in the task pool.
    retry = 5;

    // Should return true or false value (boolean) that end of the all process
    // If process rejected, current task will be removed from task pool in worker.
    return new Promise((resolve, reject) => {
      // A function is called in this example.
      // The async operation is started by resolving the promise class with the return value.
      const result = someMessageSenderFunc(message);
      if (result) {
        // Task will be completed successfully
        resolve(true);
      } else {
        // Task will be failed.
        // If retry value i not equal to 5,
        // If the retry value was not 5, it is being sent back to the pool to try again.
        resolve(false);
      }
    });
  }
}

Register worker:

Queue.workers({ MessageSenderWorker });

Create channel:

// create new queue instance with default config
const queue = new Queue();
// create a new channel
const channel = queue.create("send-message");

Add task to channel:

channel
  .add({
    label: "Send message",
    handler: "SendMessageWorker",
    args: "Hello world!",
  })
  .then(result => {
    // do something...
  });

Start queue:

channel.start();

That's it!

Documentaion

Click for detailed documentation

Tests

$ npm test

Browser Support

Name Version
Chrome 32 +
Firefox 29 +
Safari 8 +
Opera 19 +
IE 11
Edge all

Note: Listed above list by pormise support.

You can testing all others browser version at BrowserStack

BrowserStack

Change log

See CHANGELOG.md

License

MIT license

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].