vapor / queues

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

improving configuration api #39

Closed tanner0101 closed 5 years ago

tanner0101 commented 5 years ago

This is what a min-viable setup for vapor + jobs looks like currently:

let app = Application(environment: env)
app.provider(JobsProvider())
app.register(JobsDriver.self) { app in
    return TestDriver(on: app.make())
}
app.register(extension: JobsConfiguration.self) { jobs, app in
    jobs.add(FooJob())
}
app.get("foo") { req in
    return req.jobs.dispatch(FooJob.Data(foo: "bar"))
        .map { "done" }
}
return app

Not bad at all, but I have some ideas. What about something like this:

let app = Application(environment: env)
app.provider(JobsProvider())

app.jobs.driver(TestDriver())
app.jobs.add(FooJob())
app.jobs.add(BarJob())
app.jobs.add(QuxJob())

app.get("foo") { req in
    return req.jobs.dispatch(FooJob.self, .init(foo: "bar"))
        .map { "done" }
}
return app
jdmcd commented 5 years ago

I agree, I think this would be really nice.

jdmcd commented 5 years ago

Closed in #43