Closed jborges05 closed 5 years ago
I went briefly through the code and I don't really see any major problem in the implementation. What do you mean by always run the same job ? The JobCreator in your case seems to return a new instance for each job. Are you referring to the parameter that is always the same ?
Hey, I try to run similar code in my computer and seem that everything is working well. my question is as lucas34 asked is:
Closing the issue since It seems to not be a library issue.
Hello, i'm using SwiftQueue to createa upload/download queue in my app. When i try to run the queue return allways the same image for all objects in que
Can you help me? I have arround 500 images to upload but queue only run the same job for te 500 images. What i'm doing wrong, im using the last version of pod. `import Foundation import SwiftQueue import Crashlytics import Alamofire
class MIImagesInQueueDownload: NSObject, NSCoding { var url: String?
}
class MIImagesInQueueUpload: NSObject, NSCoding { var filePath: String = "" var fileName: String = "" var assignmentUUID: String = "" var url:String = ""
}
public struct ImageError: Error { let msg: String }
public struct UploadError: Error { let msg: String }
extension ImageError: LocalizedError { public var errorDescription: String? { return NSLocalizedString(msg, comment: "") } }
extension UploadError: LocalizedError { public var errorDescription: String? { return NSLocalizedString(msg, comment: "") } }
class downloadOperation: Job { let image: MIImagesInQueueDownload static let type = "downloadImage"
}
class uploadOperation: Job { let image: MIImagesInQueueUpload lazy var uploadQueue: DispatchQueue = { var queue = DispatchQueue(label: "com.uscope.photoId.ImagesUpload", qos: DispatchQoS.background, attributes: .concurrent, autoreleaseFrequency: DispatchQueue.AutoreleaseFrequency.inherit, target: DispatchQueue.global(qos: .background)) return queue }()
}
class UploaderDownloaderManager { static let shared:UploaderDownloaderManager = UploaderDownloaderManager() let queueManager = SwiftQueueManagerBuilder(creator: mainJobCreator()).set(logger: ConsoleLogger()).build()
}
class mainJobCreator: JobCreator { func create(type: String, params: [String : Any]?) -> Job { // check for job and params type if type == downloadOperation.type { return downloadOperation(image: MIImagesInQueueDownload(url: params?["fileURI"] as? String ?? "")) } else if type == uploadOperation.type { return uploadOperation(image: MIImagesInQueueUpload(filePath: params?["filePath"] as? String ?? "", fileName: params?["fileName"] as? String ?? "", assignmentUUID: params?["assignmentId"] as? String ?? "", url: params?["fileURI"] as? String ?? "")) } else { fatalError("No Job !") } } }
`