Add MIT license
Kyu is a stupidly simple, persistant, queue system.
dependencies: [ .package(url: "https://github.com/reddavis/Kyu", from: "3.0.0-beta.1") ]
Kyu has two parts to it; The Kyu, which manages job state and execution and the Job which does the actual work.
Kyu
Job
A job must simply conform to the Job and Codable protocol.
Codable
A simple “Append new line to end of file” job could look something like:
final class AppendNewLineJob: Job { let id: UUID var maximumNumberOfRetries: Int { 5 } var numberOfRetries = 0 var executionDate = Date() let fileURL: URL let string: String // MARK: Initialization init(fileURL: URL, string: String) { self.id = UUID() self.fileURL = fileURL self.string = string } // MARK: Job func execute() async throws { let fileHandle = try FileHandle(forWritingTo: self.fileURL) try fileHandle.seekToEnd() fileHandle.write("\(self.string)\n".data(using: .utf8)!) fileHandle.closeFile() } }
The Kyu manages and executes jobs. It take a URL parameter, which is where it will persist the jobs.
URL
let url = URL(string: ...)! self.kyu = try Kyu<AppendNewLineJob>(url: url) let job = AppendNewLineJob( fileURL: fileURL, string: "a string to append" ) try await kyu.add(job: job)
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
Kyu
Kyu is a stupidly simple, persistant, queue system.
Requirements
Installation
Swift Package Manager
Usage
Kyu has two parts to it; The
Kyu
, which manages job state and execution and theJob
which does the actual work.The Job
A job must simply conform to the
Job
andCodable
protocol.A simple “Append new line to end of file” job could look something like:
The Kyu
The Kyu manages and executes jobs. It take a
URL
parameter, which is where it will persist the jobs.