Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add support for running examples easily with `stack`. - Fix calls made to `threadDelay` that were using milliseconds intead of nanoseconds. - amqp-0.9 added a Bool parameter to the `qos` that was causing worker.hs to not compile. - Removed almost all use of String in favor of Lazy ByteString.
- Loading branch information
1 parent
1c7574d
commit 3b6a5e9
Showing
11 changed files
with
171 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,31 @@ | ||
{-# OPTIONS -XOverloadedStrings #-} | ||
#!/usr/bin/env stack | ||
{- stack --install-ghc | ||
runghc | ||
--package amqp | ||
--package bytestring | ||
-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
import Network.AMQP | ||
|
||
import qualified Data.ByteString.Lazy.Char8 as BL | ||
import System.Environment (getArgs) | ||
import Text.Printf | ||
import Data.Monoid ((<>)) | ||
import System.Environment (getArgs) | ||
|
||
main :: IO () | ||
main = do | ||
args <- getArgs | ||
let body = bodyFor args | ||
let body = bodyFor args | ||
conn <- openConnection "127.0.0.1" "/" "guest" "guest" | ||
ch <- openChannel conn | ||
|
||
publishMsg ch "" "task_queue" | ||
(newMsg {msgBody = (BL.pack body), | ||
(newMsg {msgBody = body, | ||
msgDeliveryMode = Just Persistent}) | ||
|
||
putStrLn $ printf " [x] Sent '%s'" (body) | ||
BL.putStrLn $ " [x] Sent " <> body | ||
closeConnection conn | ||
|
||
bodyFor :: [String] -> String | ||
bodyFor :: [String] -> BL.ByteString | ||
bodyFor [] = "Hello, world!" | ||
bodyFor xs = unwords xs | ||
bodyFor xs = BL.pack . unwords $ xs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.