packages feed

faktory 1.0.1.0 → 1.0.1.1

raw patch · 9 files changed

+53/−59 lines, 9 filesdep ~megaparsecdep ~networkPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: megaparsec, network

API changes (from Hackage documentation)

Files

README.lhs view
@@ -1,6 +1,6 @@ # faktory\_worker\_haskell -[![CircleCI](https://circleci.com/gh/frontrowed/faktory_worker_haskell.svg?style=svg)](https://circleci.com/gh/frontrowed/faktory_worker_haskell)+[![CircleCI](https://circleci.com/gh/freckle/faktory_worker_haskell.svg?style=svg)](https://circleci.com/gh/freckle/faktory_worker_haskell)  Haskell client and worker process for the Faktory background job server. @@ -38,9 +38,9 @@ - Hackage: http://hackage.haskell.org/package/faktory - Stackage: *Coming soon* -## Documentation+## Faktory Documentation -See the [wiki](//github.com/contribsys/faktory_worker_ruby/wiki) for more+See the [wiki](//github.com/contribsys/faktory/wiki) for more details.  ## Usage@@ -72,10 +72,8 @@ newtype MyJob = MyJob   { myJobMessage :: String   }-  deriving (Generic)--instance ToJSON MyJob-instance FromJSON MyJob+  deriving stock Generic+  deriving anyclass (ToJSON, FromJSON) ```  ### Worker
examples/consumer/Main.hs view
@@ -10,8 +10,8 @@  -- | Must match examples/producer newtype Job = Job { jobMessage :: String }-  deriving Generic-instance FromJSON Job+  deriving stock Generic+  deriving anyclass FromJSON  main :: IO () main = do
examples/producer/Main.hs view
@@ -4,7 +4,6 @@  import Control.Exception.Safe import Data.Aeson-import Data.Semigroup ((<>)) import Faktory.Client import Faktory.Job (perform) import Faktory.Settings@@ -13,14 +12,14 @@  -- | Must match examples/consumer newtype Job = Job { jobMessage :: String }-  deriving Generic-instance ToJSON Job+  deriving stock Generic+  deriving anyclass ToJSON  main :: IO () main = do   settings <- envSettings   bracket (newClient settings Nothing) closeClient $ \client -> do     args <- getArgs-    jobId <- perform mempty client Job {jobMessage = unwords args}+    jobId <- perform mempty client Job { jobMessage = unwords args }      putStrLn $ "Pushed job: " <> show jobId
faktory.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.18 --- This file has been generated from package.yaml by hpack version 0.31.1.+-- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack ----- hash: 66aede4bf8bc7151f329846724b6fdfb81533262091556335dcf70583b112cc1+-- hash: fe59297ff90aa80416c1575f9e03019036b581f05a2ebccc851f13748e618b5e  name:           faktory-version:        1.0.1.0+version:        1.0.1.1 synopsis:       Faktory Worker for Haskell description:    Haskell client and worker process for the Faktory background job server.                 .@@ -76,9 +76,9 @@     , bytestring >=0.1 && <1     , connection >=0.2 && <1     , cryptonite >=0.2 && <1-    , megaparsec >=7 && <8+    , megaparsec >=7 && <8.1     , memory >=0.1 && <1-    , network >=2.6 && <3+    , network >=2.6 && <3.2     , random >=1.1 && <2     , safe-exceptions >=0.1 && <1     , scanner >=0.2 && <1
library/Faktory/Client.hs view
@@ -23,7 +23,6 @@ import Data.ByteArray (ByteArrayAccess) import Data.ByteString.Lazy (ByteString, fromStrict) import qualified Data.ByteString.Lazy.Char8 as BSL8-import Data.Text (Text) import qualified Data.Text as T import qualified Data.Text.Encoding as T import Faktory.Connection (connect)@@ -47,11 +46,8 @@   }  instance FromJSON HiPayload where-  parseJSON = withObject "HiPayload" $ \o ->-    HiPayload-      <$> o .: "v"-      <*> o .:? "s"-      <*> o .:? "i"+  parseJSON = withObject "HiPayload"+    $ \o -> HiPayload <$> o .: "v" <*> o .:? "s" <*> o .:? "i"  data HelloPayload = HelloPayload   { helloWorkerId :: Maybe WorkerId@@ -63,24 +59,22 @@   }  instance ToJSON HelloPayload where-  toJSON HelloPayload{..} =-    object-      [ "wid" .= helloWorkerId-      , "hostname" .= helloHostname-      , "pid" .= helloProcessId-      , "labels" .= helloLabels-      , "v" .= helloVersion-      , "pwdhash" .= helloPasswordHash-      ]-  toEncoding HelloPayload{..} =-    pairs $ mconcat-      [ "wid" .= helloWorkerId-      , "hostname" .= helloHostname-      , "pid" .= helloProcessId-      , "labels" .= helloLabels-      , "v" .= helloVersion-      , "pwdhash" .= helloPasswordHash-      ]+  toJSON HelloPayload {..} = object+    [ "wid" .= helloWorkerId+    , "hostname" .= helloHostname+    , "pid" .= helloProcessId+    , "labels" .= helloLabels+    , "v" .= helloVersion+    , "pwdhash" .= helloPasswordHash+    ]+  toEncoding HelloPayload {..} = pairs $ mconcat+    [ "wid" .= helloWorkerId+    , "hostname" .= helloHostname+    , "pid" .= helloProcessId+    , "labels" .= helloLabels+    , "v" .= helloVersion+    , "pwdhash" .= helloPasswordHash+    ]  -- | Open a new @'Client'@ connection with the given @'Settings'@ newClient :: HasCallStack => Settings -> Maybe WorkerId -> IO Client@@ -147,7 +141,10 @@ commandOK Client {..} cmd args = withMVar clientConnection $ \conn -> do   sendUnsafe clientSettings conn cmd args   response <- recvUnsafe clientSettings conn-  unless (response == Just "OK") $ throwString "Server not OK"+  unless (response == Just "OK")+    $ throwString+    $ "Server not OK. Reply was: "+    <> show response  -- | Send a command, parse the response as JSON commandJSON
library/Faktory/Connection.hs view
@@ -31,7 +31,7 @@   , connectionInfoHostName :: HostName   , connectionInfoPort :: PortNumber   }-  deriving (Eq, Show)+  deriving stock (Eq, Show)  defaultConnectionInfo :: ConnectionInfo defaultConnectionInfo = ConnectionInfo
library/Faktory/Job.hs view
@@ -37,7 +37,7 @@   , jobQueue :: Maybe Queue   , jobAt :: Maybe UTCTime   }-  deriving Generic+  deriving stock Generic  -- | Individual changes to a @'Job'@ to be 'perform'ed data JobUpdate@@ -120,10 +120,10 @@ jobArg Job {..} = NE.head jobArgs  instance ToJSON args => ToJSON (Job args) where-   toJSON = genericToJSON $ aesonPrefix snakeCase-   toEncoding = genericToEncoding $ aesonPrefix snakeCase+  toJSON = genericToJSON $ aesonPrefix snakeCase+  toEncoding = genericToEncoding $ aesonPrefix snakeCase  instance FromJSON args => FromJSON (Job args) where-   parseJSON = genericParseJSON $ aesonPrefix snakeCase+  parseJSON = genericParseJSON $ aesonPrefix snakeCase  type JobId = String
library/Faktory/Prelude.hs view
@@ -10,7 +10,6 @@ import Control.Exception.Safe as X import Control.Monad as X import Data.Foldable as X-import Data.Semigroup as X ((<>)) import Data.Text as X (Text, pack, unpack) import Data.Traversable as X 
library/Faktory/Worker.hs view
@@ -23,25 +23,26 @@  -- | If processing functions @'throw'@ this, @'runWorker'@ will exit data WorkerHalt = WorkerHalt-  deriving (Eq, Show, Exception)+  deriving stock (Eq, Show)+  deriving anyclass Exception  newtype BeatPayload = BeatPayload   { _bpWid :: WorkerId   }-  deriving Generic+  deriving stock Generic  instance ToJSON BeatPayload where-   toJSON = genericToJSON $ aesonPrefix snakeCase-   toEncoding = genericToEncoding $ aesonPrefix snakeCase+  toJSON = genericToJSON $ aesonPrefix snakeCase+  toEncoding = genericToEncoding $ aesonPrefix snakeCase  newtype AckPayload = AckPayload   { _apJid :: JobId   }-  deriving Generic+  deriving stock Generic  instance ToJSON AckPayload where-   toJSON = genericToJSON $ aesonPrefix snakeCase-   toEncoding = genericToEncoding $ aesonPrefix snakeCase+  toJSON = genericToJSON $ aesonPrefix snakeCase+  toEncoding = genericToEncoding $ aesonPrefix snakeCase  data FailPayload = FailPayload   { _fpMessage :: Text@@ -49,11 +50,11 @@   , _fpJid :: JobId   , _fpBacktrace :: [String]   }-  deriving Generic+  deriving stock Generic  instance ToJSON FailPayload where-   toJSON = genericToJSON $ aesonPrefix snakeCase-   toEncoding = genericToEncoding $ aesonPrefix snakeCase+  toJSON = genericToJSON $ aesonPrefix snakeCase+  toEncoding = genericToEncoding $ aesonPrefix snakeCase  runWorker :: FromJSON args => Settings -> (args -> IO ()) -> IO () runWorker settings f = do