]> woffs.de Git - fd/haskell-amqp-utils.git/commitdiff
prefetch too customport
authorFrank Doepper <[email protected]>
Mon, 9 Dec 2019 12:52:04 +0000 (13:52 +0100)
committerFrank Doepper <[email protected]>
Mon, 9 Dec 2019 12:52:04 +0000 (13:52 +0100)
Network/AMQP/Utils/Helpers.hs
Network/AMQP/Utils/Options.hs
konsum.hs

index b69207d4bc74e390d3bdb568f1acbbaa4ff7dfe5..85f396cf7c039fbc165c87cf5381aee9b140ba61 100644 (file)
@@ -5,12 +5,14 @@ import Control.Concurrent
 import qualified Control.Exception as X
 import Control.Monad
 import qualified Data.ByteString.Lazy.Char8 as BL
+import Data.Int (Int64)
 import Data.List
 import qualified Data.Map as M
 import Data.Maybe
 import qualified Data.Text as T
 import Data.Time
 import Data.Time.Clock.POSIX
+import Data.Word (Word16)
 import Network.AMQP
 import Network.AMQP.Types
 import Network.AMQP.Utils.Options
@@ -61,6 +63,10 @@ instance Flexprint Bool
 
 instance Flexprint Int
 
+instance Flexprint Int64
+
+instance Flexprint Word16
+
 instance Flexprint ExitCode
 
 instance Flexprint X.SomeException
@@ -104,11 +110,11 @@ isimage (Just ctype)
   | otherwise = any (flip isPrefixOf ctype) ["application", "image"]
 
 -- | show the first bytes of message body
-anriss' :: Maybe Int -> BL.ByteString -> BL.ByteString
+anriss' :: Maybe Int64 -> BL.ByteString -> BL.ByteString
 anriss' x =
   case x of
     Nothing -> id
-    Just y -> BL.take (fromIntegral y)
+    Just y -> BL.take y
 
 -- | callback cmdline with optional parameters
 printopt :: (String, Maybe String) -> [String]
@@ -116,7 +122,7 @@ printopt (_, Nothing) = []
 printopt (opt, Just s) = [opt, s]
 
 -- | prints header and head on stderr and returns cmdline options to callback
-printmsg :: Maybe Handle -> (Message, Envelope) -> Maybe Int -> ZonedTime -> IO [String]
+printmsg :: Maybe Handle -> (Message, Envelope) -> Maybe Int64 -> ZonedTime -> IO [String]
 printmsg h (msg, envi) anR now = do
   mapM_
     (uncurry printparam)
index 8e65caa13d36f7f0c537bf9a10b8a67b9e8661a7..0a7b8e56073ff32a7cfe31ffab7a328204afd0d5 100644 (file)
@@ -1,6 +1,7 @@
 module Network.AMQP.Utils.Options where
 
 import Data.Default.Class
+import Data.Int (Int64)
 import qualified Data.Map as M
 import Data.Maybe
 import Data.Text (Text, pack)
@@ -27,14 +28,14 @@ data Args = Args
   , currentExchange :: String
   , bindings :: [(String, String)]
   , rKey :: String
-  , anRiss :: Maybe Int
+  , anRiss :: Maybe Int64
   , fileProcess :: Maybe String
   , qName :: Maybe String
   , cert :: Maybe String
   , key :: Maybe String
   , user :: String
   , pass :: String
-  , preFetch :: Int
+  , preFetch :: Word16
   , heartBeat :: Maybe Word16
   , tempDir :: Maybe String
   , additionalArgs :: [String]
@@ -317,7 +318,7 @@ allOptions =
     , Option
         ['l']
         ["charlimit"]
-        (ReqArg (\s o -> o {anRiss = Just (read s :: Int)}) "INT")
+        (ReqArg (\s o -> o {anRiss = Just (read s)}) "INT")
         "limit number of shown body chars (default: unlimited)")
   , ( "kr"
     , Option
index 1c0f933b5e291c53b5514422e72fe86d59205b01..178ad18d85c7d76f63823aca6ee78062da290770 100644 (file)
--- a/konsum.hs
+++ b/konsum.hs
@@ -23,7 +23,7 @@ main = do
   addChannelExceptionHandler chan (X.throwTo tid)
   -- set prefetch
   printparam "prefetch" $ preFetch args
-  qos chan 0 (fromIntegral $ preFetch args) False
+  qos chan 0 (preFetch args) False
   -- attach to given queue? or build exclusive queue and bind it?
   queue <-
     maybe
don't click here