yesod-worker alternatives and similar packages
Based on the "yesod" category.
Alternatively, view yesod-worker alternatives based on common mentions on social networks and blogs.
-
yesod-dsl
A domain specific language and a code generator desined to create RESTful services for managing an RDBMS with Yesod web framework and Persistent. -
yesod-raml
Generate Yesod framework route definitions, documentaiton, mock-handler, and more from your RAML spec. -
yesod-datatables
Routines for implementing server-side processing for DataTables (jQuery grid) in Haskell -
yesod-auth-hmac-keccak
DISCONTINUED. An account authentication plugin for yesod with encrypted token transfer.
WorkOS - The modern identity platform for B2B SaaS
Do you think we are missing an alternative of yesod-worker or a related project?
README
A Sidekiq-compatible background worker system, built on Keenser and using Redis for job persistence
Usage
See the demo for an example setup
Define Your Jobs
In e.g. Jobs.hs
import Yesod.Worker
blah :: Worker Handler (Text, Int)
-- Worker name (should be unique), queue name, then arg list
blah = Worker "blah" "default" $ \(word, n) ->
-- Your long-running work goes here
-- N.B. this runs in the Yesod Handler monad, but doesn't have access to
-- anything request- or response- related. Under the hood, it's using
-- `unsafeHandler`, and may error if you try to e.g. redirect. A future
-- version will include a `Handler`-like monad stack which should be
-- safe from these sorts of errors.
replicateM_ n $ do
$(logWarn) word
liftIO . threadDelay $ 1000000
setup = do
register blah
-- register any other jobs you like
-- they need not have the same argument type
Include the Subsite
In Foundation.hs
import Yesod.Worker
data App = App
{ ...
, getWorkers :: Workers
}
instance YesodWorker App where
workers = getWorkers
In Application.hs
import Yesod.Worker
import Jobs
makeFoundation = do
...
getWorkers <- newWorkers
...
makeApplication foundation = do
unsafeHandler foundation $ do
bootWorkers setup
-- optionally, queue jobs on app boot:
enqueue blah ("queued at start", 2)
Queue Up a Job
In e.g. Handlers/Whatever.hs
import Yesod.Worker
import Jobs
postHandlerR = do
enqueue blah ("na", 16)
...
Watch the Stats
Add a route
/workers WorkerR Workers getWorkers
and visit /workers
Over time, this page should expand to a Sidekiq-style administration panel, allowing for closer monitoring and options for retrying from the web UI.
Note that the Redis interface is already Sidekiq compatable, so you can literally use sidekiq/web
for monitoring as well.