Comments (6)
I don't think this is supported yet. Maybe this would be a good API:
app.jobs.schedule(SomeJob()).minutely().every(10)
from queues.
Would be cool if the schedule builder was public as well so you can implement your own, e.g.:
app.jobs.schedule(SomeJob()).custom(SolarNoonScheduler(lat: 78.651, long: 376.990))
from queues.
Issue seems to be quiet but I too would love this functionality, my workaround is very much similar to Kevin's. Though I've made it a little more flexible in an extension
extension Application.Queues {
func scheduleEvery(_ job: ScheduledJob, minutes: Int) {
for minuteOffset in stride(from: 0, to: 60, by: minutes) {
schedule(job).hourly().at(.init(integerLiteral: minuteOffset))
}
}
}
from queues.
ok.. so I kinda found that this works. for doing something every 10 mins.. but surely we can come up with something easier:
app.jobs.schedule(ApiPerformanceJob(app)).hourly().at(ScheduleBuilder.Minute(integerLiteral: 0))
app.jobs.schedule(ApiPerformanceJob(app)).hourly().at(ScheduleBuilder.Minute(integerLiteral: 10))
app.jobs.schedule(ApiPerformanceJob(app)).hourly().at(ScheduleBuilder.Minute(integerLiteral: 20))
app.jobs.schedule(ApiPerformanceJob(app)).hourly().at(ScheduleBuilder.Minute(integerLiteral: 30))
app.jobs.schedule(ApiPerformanceJob(app)).hourly().at(ScheduleBuilder.Minute(integerLiteral: 40))
app.jobs.schedule(ApiPerformanceJob(app)).hourly().at(ScheduleBuilder.Minute(integerLiteral: 50))
from queues.
@tanner0101 That looks like it would make sense.. everything I was thinking about the other day.. just didn't convey what it should do.
from queues.
My temporary approach for running a job every 5 minutes:
struct MyJob : ScheduledJob {
// start with 4 to ensure first run happens immediately
static var inter: Int = 4
func run(c: QueueContext) -> EventLoopFuture<Void> {
// internal counter increments by one, modulo 5 (so wraps to 0 every five minutes)
MyJob = (MyJob + 1) % 5
if MyJob > 0 {
return context.eventLoop.future()
}
//
// --- do actual work --
...
}
}
from queues.
Related Issues (20)
- Make a Vapor Queue Sequential HOT 3
- Allow getting connection pools for an event loop in clients HOT 10
- Output to Swift Metrics
- Let the driver determine the appropriate payload storage format HOT 3
- Event delegate for scheduled jobs
- Supplying an Application instance when dequeuing a job HOT 2
- Support for setting a JobIdentifier for a job HOT 4
- Remove deprecation for V1 HOT 1
- Provide a Fluent-backed driver? HOT 2
- In process queues worker crash on Ctrl+c to exit server HOT 1
- ScheduledJob management [Draft] HOT 3
- "JobsCommand did not shutdown before deinit" when run unit tests HOT 2
- Retry delay HOT 8
- More informative error reporting about what job is failing HOT 2
- Add option to configure number of workers
- Scheduling a ScheduledJob hourly runs a few seconds early and reschedules thus running twice HOT 23
- Queues does not support Swift 5.2 HOT 2
- Queues Package for official MongoDB Swift Driver
- ScheduledJob run twice quickly because actual sleep duration is shorter than expected.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from queues.