packages feed

faktory 1.0.0.0 → 1.0.1.0

raw patch · 6 files changed

+30/−186 lines, 6 filesdep ~megaparsecPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: megaparsec

API changes (from Hackage documentation)

+ Faktory.Job: data JobOptions

Files

CHANGELOG.md view
@@ -1,6 +1,10 @@-## [*Unreleased*](https://github.com/frontrowed/faktory_worker_haskell/compare/v1.0.0.0...master)+## [*Unreleased*](https://github.com/frontrowed/faktory_worker_haskell/compare/v1.0.1.0...master)  None++## [v1.0.1.0](https://github.com/frontrowed/faktory_worker_haskell/compare/v1.0.0.0...1.0.1.0)++- Upgrade to `megaparsec-7`  ## [v1.0.0.0](https://github.com/frontrowed/faktory_worker_haskell/tree/v1.0.0.0) 
README.lhs view
@@ -35,7 +35,8 @@  ## Installation -TODO.+- Hackage: http://hackage.haskell.org/package/faktory+- Stackage: *Coming soon*  ## Documentation 
− README.md
@@ -1,175 +0,0 @@-# faktory\_worker\_haskell--[![CircleCI](https://circleci.com/gh/frontrowed/faktory_worker_haskell.svg?style=svg)](https://circleci.com/gh/frontrowed/faktory_worker_haskell)--Haskell client and worker process for the Faktory background job server.--Architecture overview from [Ruby client README](https://github.com/contribsys/faktory_worker_ruby#readme):--```-                       +--------------------+-                       |                    |-                       |     Faktory        |-                       |     Server         |-        +---------->>>>|                    +>>>>--------+-        |              |                    |            |-        |              |                    |            |-        |              +--------------------+            |-+-----------------+                            +-------------------+-|                 |                            |                   |-|    Client       |                            |     Worker        |-|    pushes       |                            |     pulls         |-|     jobs        |                            |      jobs         |-|                 |                            |                   |-|                 |                            |                   |-+-----------------+                            +-------------------+-```--- Client - an API any process can use to push jobs to the Faktory server.-- Worker - a process that pulls jobs from Faktory and executes them.-- Server - the Faktory daemon which stores background jobs in queues to be-  processed by Workers.--This package contains only the client and worker parts. The server part is-[here](https://github.com/contribsys/faktory/)--## Installation--TODO.--## Documentation--See the [wiki](//github.com/contribsys/faktory_worker_ruby/wiki) for more-details.--## Usage--<!---```haskell-import Data.Aeson-import Prelude-import Faktory.Client-import Faktory.Job-import Faktory.Settings-import Faktory.Worker-import GHC.Generics--{- Don't actually run anything -}-main :: IO ()-main = if True then pure () else (workerMain >> clientMain)-workerMain :: IO ()-clientMain :: IO ()-```--->--### Job--Any value can be a "Job" that is pushed and pulled to and from Faktory via its-`ToJSON` and `FromJSON` instances:--```haskell-newtype MyJob = MyJob-  { myJobMessage :: String-  }-  deriving (Generic)--instance ToJSON MyJob-instance FromJSON MyJob-```--### Worker--```haskell-workerMain = do-  settings <- envSettings--  runWorker settings $ \job ->-    -- Process your Job here-    putStrLn $ myJobMessage job--    -- If any exception is thrown, the job will be marked as Failed in Faktory-    -- and retried. Note: you will not otherwise hear about any such exceptions,-    -- unless you catch-and-rethrow them yourself.-```--### Client--```haskell-clientMain = do-  settings <- envSettings-  client <- newClient settings Nothing -- N.B. A WorkerId is not necessary if-                                       -- only pushing Jobs.--  jobId <- perform mempty client $ MyJob "Hello world"--  print jobId--  closeClient client-```--### Configuration--When using `envSettings`, the following variables will be used:--- `FAKTORY_QUEUE`: the name of the queue to consume from. This is Worker-only,-  for `perform`, a non-default Queue should be given by the `queue` option-- `FAKTORY_PROVIDER`: the name of another environment variable where the-  connection string can be found. Defaults to `FAKTORY_URL`.-- `FAKTORY_URL` (or whatever you named in `FAKTORY_PROVIDER`): connection string-  to the Faktory server. Format is `tcp(+tls)://(:password@)host:port`. Defaults-  to `tcp://localhost:4719`.--## Examples--See the [examples](./examples). To run them:--1. Run a local Faktory server--   ```console-   docker run --rm \-     --publish 7419:7419 \-     --publish 7420:7420 \-     contribsys/faktory-   ```--1. Run the consumer example--   ```console-   % stack exec faktory-example-consumer-   Starting consumer loop-   ```--   (Assumes you've built the project.)--1. Submit a Job through the producer example--   ```console-   % stack exec faktory-example-producer hello world-   Pushed job: "ljcjlbexbgun"-   ```--   *NOTE*: if you submit "BOOM" as a Job, the processing loop will raise an-   exception, so you can see how a Failed Job looks in Faktory.--1. See that your Job was processed back in the consumer--   ```console-   % stack exec faktory-example-consumer-   Starting consumer loop-   hello world-   ```--## Development & Tests--```console-stack build --dependencies-only --test --no-run-tests-stack build --pedantic --test --no-run-tests-stack build --pedantic --test-```--*NOTE*: `FactorySpec` requires a local Faktory server is running, and it will-flush all Jobs from this server as part of running the tests.-------[CHANGELOG](./CHANGELOG.md) | [LICENSE](./LICENSE)
faktory.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 5b58d182a42e13721957b2b5e0234d010b79698c8ed5197f94a5a14d5114964c+-- hash: 66aede4bf8bc7151f329846724b6fdfb81533262091556335dcf70583b112cc1  name:           faktory-version:        1.0.0.0+version:        1.0.1.0 synopsis:       Faktory Worker for Haskell description:    Haskell client and worker process for the Faktory background job server.                 .@@ -45,11 +45,10 @@ copyright:      2018 Freckle Education license:        MIT license-file:   LICENSE-tested-with:    GHC==8.4.3 build-type:     Simple extra-doc-files:     CHANGELOG.md-    README.md+    README.lhs  source-repository head   type: git@@ -77,7 +76,7 @@     , bytestring >=0.1 && <1     , connection >=0.2 && <1     , cryptonite >=0.2 && <1-    , megaparsec >=6.5 && <7+    , megaparsec >=7 && <8     , memory >=0.1 && <1     , network >=2.6 && <3     , random >=1.1 && <2
library/Faktory/Connection.hs view
@@ -7,13 +7,23 @@  import Faktory.Prelude +import Control.Applicative ((<|>)) import Data.Maybe (fromMaybe) import Data.Void import Network.Connection import Network.Socket (HostName, PortNumber) import System.Environment (lookupEnv) import Text.Megaparsec-import Text.Megaparsec.Char+  ( Parsec+  , anySingle+  , errorBundlePretty+  , manyTill+  , optional+  , parse+  , some+  , (<?>)+  )+import Text.Megaparsec.Char (char, digitChar, string, upperChar)  data ConnectionInfo = ConnectionInfo   { connectionInfoTls :: Bool@@ -74,7 +84,7 @@   err ex = throwIO . userError $ unlines     [ ""     , "\"" <> value <> "\" is an invalid value for " <> name <> ":"-    , parseErrorPretty ex+    , errorBundlePretty ex     ]  parseProvider :: Parser String@@ -87,6 +97,6 @@   go =     ConnectionInfo       <$> (False <$ string "tcp://" <|> True <$ string "tcp+tls://")-      <*> optional (char ':' *> manyTill anyChar (char '@'))-      <*> manyTill anyChar (char ':')+      <*> optional (char ':' *> manyTill anySingle (char '@'))+      <*> manyTill anySingle (char ':')       <*> (read <$> some digitChar)
library/Faktory/Job.hs view
@@ -1,6 +1,7 @@ module Faktory.Job   ( Job   , JobId+  , JobOptions   , perform   , retry   , once@@ -46,6 +47,10 @@   | SetAt UTCTime   | SetIn NominalDiffTime +-- | Options for the execution of a job+--+-- See @'perform'@ for more details.+-- newtype JobOptions = JobOptions [JobUpdate]   deriving newtype (Semigroup, Monoid)