Created
March 4, 2026 12:01
-
-
Save jacobsapps/f352d3e08f768681d23e5c5cf898042b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private func processQueueIfNeeded() async { | |
| guard !isProcessing else { return } | |
| isProcessing = true | |
| defer { isProcessing = false } | |
| while let nextJob = fetchNextOutstandingJobSnapshot() { | |
| do { | |
| try withJob(nextJob.id) { _, job in | |
| job.state = .uploading | |
| job.attempts += 1 | |
| job.lastError = nil | |
| job.updatedAt = .now | |
| } | |
| try await submitLevel4Tweet(text: nextJob.text) | |
| try withJob(nextJob.id) { context, job in context.delete(job) } | |
| } catch { | |
| try? withJob(nextJob.id) { _, job in | |
| job.state = .failed | |
| job.lastError = error.localizedDescription | |
| job.updatedAt = .now | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment