All Projects → lucas34 → Swiftqueue

lucas34 / Swiftqueue

Licence: mit
Job Scheduler for IOS with Concurrent run, failure/retry, persistence, repeat, delay and more

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Swiftqueue

Workq
Job server in Go
Stars: ✭ 1,546 (+460.14%)
Mutual labels:  scheduler, job-scheduler, job, queue
orkid-node
Reliable and modern Redis Streams based task queue for Node.js 🤖
Stars: ✭ 61 (-77.9%)
Mutual labels:  queue, job, job-scheduler
nest-queue
Queue manager for NestJS Framework for Redis (via bull package)
Stars: ✭ 69 (-75%)
Mutual labels:  queue, job, job-scheduler
Jiacrontab
简单可信赖的任务管理工具
Stars: ✭ 1,052 (+281.16%)
Mutual labels:  scheduler, job-scheduler, job
Go Quartz
Simple, zero-dependency scheduling library for Go
Stars: ✭ 118 (-57.25%)
Mutual labels:  scheduler, job-scheduler, job
yerbie
A blazing fast job queue built for ease of use and scalability
Stars: ✭ 16 (-94.2%)
Mutual labels:  queue, scheduler, job-scheduler
linda
Linda is a simple dispatcher library.
Stars: ✭ 12 (-95.65%)
Mutual labels:  queue, job, scheduler
Bull
Premium Queue package for handling distributed jobs and messages in NodeJS.
Stars: ✭ 11,748 (+4156.52%)
Mutual labels:  scheduler, job, queue
ptScheduler
Pretty tiny Scheduler or ptScheduler is an Arduino library for writing non-blocking periodic tasks easily.
Stars: ✭ 14 (-94.93%)
Mutual labels:  scheduler, delay
Akka.Quartz.Actor
Quartz scheduling actor
Stars: ✭ 50 (-81.88%)
Mutual labels:  job, scheduler
tasq
A simple task queue implementation to enqeue jobs on local or remote processes.
Stars: ✭ 83 (-69.93%)
Mutual labels:  queue, job-scheduler
YACLib
Yet Another Concurrency Library
Stars: ✭ 193 (-30.07%)
Mutual labels:  job, scheduler
croner
Trigger functions and/or evaluate cron expressions in JavaScript. No dependencies. Most features. All environments.
Stars: ✭ 169 (-38.77%)
Mutual labels:  job, scheduler
sched
⏳ a high performance reliable task scheduling package in Go.
Stars: ✭ 46 (-83.33%)
Mutual labels:  scheduler, persistence
wtsqs
Simplified Node AWS SQS Worker Wrapper
Stars: ✭ 18 (-93.48%)
Mutual labels:  queue, job
joobq
JoobQ is a fast, efficient asynchronous reliable job queue and job scheduler library processing. Jobs are submitted to a job queue, where they reside until they are able to be scheduled to run in a computing environment.
Stars: ✭ 26 (-90.58%)
Mutual labels:  queue, scheduler
legacy-bottlerockets
Node.js high availability queue and scheduler for background job processing
Stars: ✭ 25 (-90.94%)
Mutual labels:  queue, job
gronx
Lightweight, fast and dependency-free Cron expression parser (due checker), task scheduler and/or daemon for Golang (tested on v1.13 and above) and standalone usage
Stars: ✭ 206 (-25.36%)
Mutual labels:  scheduler, job-scheduler
go-xxl-job-client
xxl-job go client
Stars: ✭ 36 (-86.96%)
Mutual labels:  scheduler, job-scheduler
reactr
Function scheduler for Go & WebAssembly
Stars: ✭ 264 (-4.35%)
Mutual labels:  scheduler, job-scheduler

SwiftQueue

Schedule tasks with constraints made easy.

Awesome platform swift Swift codecov pod Carthage compatible Swift Package Manager compatible Documentation

SwiftQueue is a job scheduler for iOS inspired by popular android libraries like android-priority-jobqueue or android-job. It allows you to run your tasks with run and retry constraints.

Library will rely on Operation and OperationQueue to make sure all tasks will run in order. Don't forget to check our WIKI.

Features

  • [x] Sequential or Concurrent execution
  • [x] Persistence
  • [x] Cancel all, by id or by tag
  • [x] Start / Stop queue

Job Constraints:

  • [x] Delay
  • [x] Deadline
  • [x] Timeout
  • [x] Internet
  • [x] Charging
  • [x] Single instance in queue
  • [x] Retry: Max count, exponential backoff
  • [x] Periodic: Max run, interval delay
  • [x] Experimental Foreground or Background execution

Requirements

  • iOS 8.0+, watchOS 2.0+, macOS 10.10+, tvOS 9.0+
  • Xcode 11.0

Installation

SwiftPackageManager (SPM)

To integrate using Apple's Swift package manager, add the following as a dependency to your Package.swift:

.package(url: "https://github.com/lucas34/SwiftQueue.git", .upToNextMajor(from: "4.0.0"))

Carthage

SwiftQueue is carthage compatible. Add the following entry in your Cartfile:

github "lucas34/SwiftQueue"

Then run carthage update.

CocoaPods

You can use CocoaPods to install SwiftQueue by adding it to your Podfile:

platform :ios, '8.0'
use_frameworks!
pod 'SwiftQueue'

In your application, simply import the library

import SwiftQueue

Example

This example will simply wrap an api call. Create your custom job by extending Job with onRun, onRetry and onRemove callbacks.

// A job to send a tweet
class SendTweetJob: Job {
    
    // Type to know which Job to return in job creator
    static let type = "SendTweetJob"
    // Param
    private let tweet: [String: Any]

    required init(params: [String: Any]) {
        // Receive params from JobBuilder.with()
        self.tweet = params
    }

    func onRun(callback: JobResult) {
        let api = Api()
        api.sendTweet(data: tweet).execute(onSuccess: {
            callback.done(.success)
        }, onError: { error in
            callback.done(.fail(error))
        })
    }

    func onRetry(error: Error) -> RetryConstraint {
        // Check if error is non fatal
        return error is ApiError ? RetryConstraint.cancel : RetryConstraint.retry(delay: 0) // immediate retry
    }

    func onRemove(result: JobCompletion) {
        // This job will never run anymore  
        switch result {
            case .success:
                // Job success
            break
            
            case .fail(let error):
                // Job fail
            break
       
        }
    }
}

Create your SwiftQueueManager and keep the reference. If you want to cancel a job it has to be done with the same instance.

let manager = SwiftQueueManagerBuilder(creator: TweetJobCreator()).build()

Schedule your job and specify the constraints.

JobBuilder(type: SendTweetJob.type)
        // Requires internet to run
        .internet(atLeast: .cellular)
        // params of my job
        .with(params: ["content": "Hello world"])
        // Add to queue manager
        .schedule(manager: manager)

Bind your job type with an actual instance.

class TweetJobCreator: JobCreator {

    // Base on type, return the actual job implementation
    func create(type: String, params: [String: Any]?) -> Job {
        // check for job and params type
        if type == SendTweetJob.type  {
            return SendTweetJob(params: params)
        } else {
            // Nothing match
            // You can use `fatalError` or create an empty job to report this issue.
            fatalError("No Job !")
        }
    }
}

3rd Party Extensions

Contributors

We would love you for the contribution to SwiftQueue, check the LICENSE file for more info.

License

Distributed under the MIT license. See LICENSE for more information.

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].