Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- mkConfig :: (LogLevel -> LogEvent -> IO ()) -> TableName -> Pool Connection -> ConcurrencyControl -> (Job -> IO ()) -> (Config -> Config) -> Config
- defaultLogStr :: (Job -> Text) -> LogLevel -> LogEvent -> LogStr
- defaultJobToHtml :: (Job -> Text) -> [Job] -> IO [Html ()]
- defaultErrorToHtml :: Value -> Html ()
- defaultJobContent :: Value -> Value
- defaultPayloadToHtml :: Value -> Html ()
- defaultJobTypeSql :: Query
- defaultConstantJobTypes :: forall a. (Generic a, ConNames (Rep a)) => Proxy a -> AllJobTypes
- defaultDynamicJobTypes :: TableName -> Query -> AllJobTypes
- defaultJobType :: Job -> Text
- defaultPollingInterval :: Seconds
- withConnectionPool :: MonadUnliftIO m => Either ByteString ConnectInfo -> (Pool Connection -> m a) -> m a
- defaultTimedLogger :: TimedFastLogger -> (LogLevel -> LogEvent -> LogStr) -> LogLevel -> LogEvent -> IO ()
- defaultJsonLogEvent :: LogEvent -> Value
- defaultJsonJob :: Job -> Value
- defaultJsonFailureMode :: FailureMode -> Value
Documentation
:: (LogLevel -> LogEvent -> IO ()) | "Structured logging" function. Ref: |
-> TableName | DB table which holds your jobs. Ref: |
-> Pool Connection | DB connection-pool to be used by job-runner. Ref: |
-> ConcurrencyControl | Concurrency configuration. Ref: |
-> (Job -> IO ()) | The actual "job runner" which contains your application code. Ref: |
-> (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 |
-> Config | The final |
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).
defaultErrorToHtml :: Value -> Html () Source #
defaultJobContent :: Value -> Value Source #
defaultPayloadToHtml :: Value -> Html () Source #
defaultConstantJobTypes :: forall a. (Generic a, ConNames (Rep a)) => Proxy a -> AllJobTypes Source #
defaultDynamicJobTypes :: TableName -> Query -> AllJobTypes Source #
defaultJobType :: Job -> Text 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 | SendPasswordResetEmail Text | 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.
Note: If your job payload does not conform to the structure described above, please read the section on customising the job payload's structure in the implementation guide.
defaultPollingInterval :: Seconds Source #
As the name says. Ref: cfgPollingInterval
withConnectionPool :: MonadUnliftIO m => Either ByteString ConnectInfo -> (Pool Connection -> m a) -> m a Source #
Convenience function to create a DB connection-pool with some sensible defaults. Please see the source-code of this function to understand what it's doing.
defaultTimedLogger :: TimedFastLogger -> (LogLevel -> LogEvent -> LogStr) -> LogLevel -> LogEvent -> IO () Source #
A convenience function to help you define a timed-logger with some sensible defaults.
defaultJsonLogEvent :: LogEvent -> Value Source #
defaultJsonJob :: Job -> Value Source #