{"id":938,"url":"https://github.com/lucas34/SwiftQueue","last_synced_at":"2025-07-30T19:33:14.810Z","repository":{"id":37451061,"uuid":"99915359","full_name":"lucas34/SwiftQueue","owner":"lucas34","description":"Job Scheduler for IOS with Concurrent run, failure/retry, persistence, repeat, delay and more","archived":false,"fork":false,"pushed_at":"2024-10-28T15:17:57.000Z","size":797,"stargazers_count":410,"open_issues_count":3,"forks_count":43,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-11-14T11:41:32.848Z","etag":null,"topics":["constraints","delay","job","job-scheduler","operation","operationqueue","persist","persistence","queue","scheduler","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucas34.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-10T11:21:35.000Z","updated_at":"2024-10-27T05:42:26.000Z","dependencies_parsed_at":"2023-02-08T16:16:44.057Z","dependency_job_id":null,"html_url":"https://github.com/lucas34/SwiftQueue","commit_stats":null,"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucas34%2FSwiftQueue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucas34%2FSwiftQueue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucas34%2FSwiftQueue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucas34%2FSwiftQueue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucas34","download_url":"https://codeload.github.com/lucas34/SwiftQueue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228179054,"owners_count":17881131,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["constraints","delay","job","job-scheduler","operation","operationqueue","persist","persistence","queue","scheduler","swift"],"created_at":"2024-01-05T20:15:35.050Z","updated_at":"2024-12-04T19:32:28.851Z","avatar_url":"https://github.com/lucas34.png","language":"Swift","readme":"# SwiftQueue\n\u003e Schedule tasks with constraints made easy.\n\n[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)\n[![platform](https://img.shields.io/badge/platforms-iOS%20%7C%20macOS%20%7C%20tvOS%20%7C%20watchOS%20-333333.svg)](https://cocoapods.org/pods/SwiftQueue)\n[![swift](https://img.shields.io/badge/Swift-4.2%20%20%7C%205.0-orange.svg)](https://swift.org)\n![Swift](https://github.com/lucas34/SwiftQueue/workflows/Swift/badge.svg)\n[![codecov](https://codecov.io/gh/lucas34/SwiftQueue/branch/master/graph/badge.svg)](https://codecov.io/gh/lucas34/SwiftQueue)\n[![pod](https://img.shields.io/cocoapods/v/SwiftQueue.svg?style=flat)](https://cocoapods.org/pods/SwiftQueue)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)\n[![Documentation](https://lucas34.github.io/SwiftQueue/badge.svg)](https://lucas34.github.io/SwiftQueue)\n\n`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. \n\nLibrary will rely on `Operation` and `OperationQueue` to make sure all tasks will run in order. Don't forget to check our [**WIKI**](https://github.com/lucas34/SwiftQueue/wiki). \n\n## Features\n\n- [x] Sequential or Concurrent execution\n- [x] Persistence\n- [x] Cancel all, by id or by tag\n- [x] Start / Stop queue\n\nJob Constraints:\n\n- [x] Delay\n- [x] Deadline\n- [x] Timeout\n- [x] Internet\n- [x] Charging\n- [x] Single instance in queue\n- [x] Retry: Max count, exponential backoff\n- [x] Periodic: Max run, interval delay\n- [x] *Experimental* Foreground or Background execution\n\n\n## Requirements\n\n- iOS 8.0+, watchOS 2.0+, macOS 10.10+, tvOS 9.0+\n- Xcode 11.0\n\n## Installation\n\n#### SwiftPackageManager (SPM)\n\nTo integrate using Apple's Swift package manager, add the following as a dependency to your Package.swift:\n\n```swift\n.package(url: \"https://github.com/lucas34/SwiftQueue.git\", .upToNextMajor(from: \"4.0.0\"))\n```\n\n#### Carthage\n`SwiftQueue` is `carthage` compatible. Add the following entry in your `Cartfile`:\n\n```\ngithub \"lucas34/SwiftQueue\"\n```\n\nThen run `carthage update`.\n\n#### CocoaPods\nYou can use [CocoaPods](https://cocoapods.org/pods/SwiftQueue) to install `SwiftQueue` by adding it to your `Podfile`:\n\n```ruby\nplatform :ios, '8.0'\nuse_frameworks!\npod 'SwiftQueue'\n```\n\nIn your application, simply import the library\n\n``` swift\nimport SwiftQueue\n```\n## Example\nThis example will simply wrap an api call. Create your custom job by extending `Job` with `onRun`, `onRetry` and `onRemove` callbacks.\n\n```swift\n// A job to send a tweet\nclass SendTweetJob: Job {\n    \n    // Type to know which Job to return in job creator\n    static let type = \"SendTweetJob\"\n    // Param\n    private let tweet: [String: Any]\n\n    required init(params: [String: Any]) {\n        // Receive params from JobBuilder.with()\n        self.tweet = params\n    }\n\n    func onRun(callback: JobResult) {\n        let api = Api()\n        api.sendTweet(data: tweet).execute(onSuccess: {\n            callback.done(.success)\n        }, onError: { error in\n            callback.done(.fail(error))\n        })\n    }\n\n    func onRetry(error: Error) -\u003e RetryConstraint {\n        // Check if error is non fatal\n        return error is ApiError ? RetryConstraint.cancel : RetryConstraint.retry(delay: 0) // immediate retry\n    }\n\n    func onRemove(result: JobCompletion) {\n        // This job will never run anymore  \n        switch result {\n            case .success:\n                // Job success\n            break\n            \n            case .fail(let error):\n                // Job fail\n            break\n       \n        }\n    }\n}\n```\n\nCreate your `SwiftQueueManager` and **keep the reference**. If you want to cancel a job it has to be done with the same instance.\n\n```swift\nlet manager = SwiftQueueManagerBuilder(creator: TweetJobCreator()).build()\n```\n\nSchedule your job and specify the constraints.\n\n```swift\nJobBuilder(type: SendTweetJob.type)\n        // Requires internet to run\n        .internet(atLeast: .cellular)\n        // params of my job\n        .with(params: [\"content\": \"Hello world\"])\n        // Add to queue manager\n        .schedule(manager: manager)\n```\n\nBind your `job` type with an actual instance.\n\n```swift\nclass TweetJobCreator: JobCreator {\n\n    // Base on type, return the actual job implementation\n    func create(type: String, params: [String: Any]?) -\u003e Job {\n        // check for job and params type\n        if type == SendTweetJob.type  {\n            return SendTweetJob(params: params)\n        } else {\n            // Nothing match\n            // You can use `fatalError` or create an empty job to report this issue.\n            fatalError(\"No Job !\")\n        }\n    }\n}\n```\n\n## 3rd Party Extensions\n\n* [SQLitePersisterForSwiftQueue](https://github.com/gumbright/SQLitePersisterForSwiftQueue): A SQLite3 based persister for SwiftQueue\n\n## Contributors\n\nWe would love you for the contribution to **SwiftQueue**, check the [`LICENSE`](LICENSE) file for more info.\n\n* [Lucas Nelaupe](http://www.lucas-nelaupe.fr/) - [@lucas34990](https://twitter.com/lucas34990)\n\n## License\n\nDistributed under the MIT license. See [`LICENSE`](LICENSE) for more information.\n","funding_links":[],"categories":["Concurrency"],"sub_categories":["Linter","Other free courses"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucas34%2FSwiftQueue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucas34%2FSwiftQueue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucas34%2FSwiftQueue/lists"}