odd-jobs-0.2.1: A full-featured PostgreSQL-backed job queue (with an admin UI)

OddJobs.ConfigBuilder

Synopsis

Documentation

Arguments

 :: (LogLevel -> LogEvent -> IO ()) "Structured logging" function. Ref: cfgLogger -> TableName DB table which holds your jobs. Ref: cfgTableName -> Pool Connection DB connection-pool to be used by job-runner. Ref: cfgDbPool -> ConcurrencyControl Concurrency configuration. Ref: cfgConcurrencyControl -> (Job -> IO ()) The actual "job runner" which contains your application code. Ref: cfgJobRunner -> (Config -> Config) A function that allows you to modify the "interim config". The "interim config" will cotain a bunch of in-built default config params, along with the config params that you've just provided (i.e. logging function, table name, DB pool, etc). You can use this function to override values in the "interim config". If you do not wish to modify the "interim config" just pass id as an argument to this parameter. Note: it is strongly recommended that you do not modify the generated Config outside of this function, unless you know what you're doing. -> Config The final Config that can be used to start various job-runners

This function gives you a Config with a bunch of sensible defaults already applied. It requires the bare minimum configuration parameters that this library cannot assume on your behalf.

It makes a few important assumptions about your 'jobPayload 'JSON, which are documented in defaultJobType.

defaultLogStr :: (Job -> Text) -> LogLevel -> LogEvent -> LogStr Source #

If you aren't interested in structured logging, you can use this function to emit plain-text logs (or define your own).

defaultJobToHtml :: (Job -> Text) -> [Job] -> IO [Html ()] Source #

This makes two important assumptions. First, this assumes that jobs in your app are represented by a sum-type. For example:

data MyJob = SendWelcomeEmail Int
| SetupSampleData Int


Second, it assumes that the JSON representatin of this sum-type is "tagged". For example, the following...

let pload = SendWelcomeEmail 10

...when converted to JSON, would look like...

{"tag":"SendWelcomeEmail", "contents":10}

It uses this assumption to extract the "job type" from a Value (which would be SendWelcomeEmail in the example given above). This is used in logging and the admin UI.

Even if tihs assumption is violated, the job-runner should continue to function. It's just that you won't get very useful log messages.

As the name says. Ref: cfgPollingInterval