vapor / queues

A queue system for Vapor.
MIT License
169 stars 41 forks source link

fluent scheduler #15

Closed tanner0101 closed 5 years ago

tanner0101 commented 5 years ago

This PR enhances the job scheduler in an attempt to make usage more fluent.

Here are some examples:

var config = JobsConfiguration()

// yearly
config.schedule(Cleanup())
    .yearly()
    .in(.may)
    .on(23)
    .at(.noon)

// monthly
config.schedule(Cleanup())
    .monthly()
    .on(15)
    .at(.midnight)

// weekly
config.schedule(Cleanup())
    .weekly()
    .on(.monday)
    .at("3:13am")

// daily
config.schedule(Cleanup())
    .daily()
    .at("5:23pm")

// daily 2
config.schedule(Cleanup())
    .daily()
    .at(5, 23, .pm)

// daily 3
config.schedule(Cleanup())
    .daily()
    .at(17, 23)

// hourly
config.schedule(Cleanup())
    .hourly()
    .at(30)

Misconfiguration uses fatal errors / precondition for the most part to make debugging easy while keeping a clean API.

Screen Shot 2019-06-12 at 1 42 57 AM
jdmcd commented 5 years ago

This is awesome! Let's use this API to build out the RecurrenceRule objects from @rnantes. I am going to push a few more changes and then we can merge and then I'll get to work on fitting in the RecurrenceRules

jdmcd commented 5 years ago

@tanner0101 Updated documentation in https://github.com/vapor/documentation/pull/389, this should be ready to go

penny-coin commented 5 years ago

Hey @tanner0101, you just merged a pull request, have a coin!

You now have 1280 coins.