module Faktory.Settings.Queue ( Queue (..) , namespaceQueue , queueArg , defaultQueue , Namespace (..) ) where import Faktory.Prelude import Data.Aeson import Data.ByteString.Lazy (ByteString, fromStrict) import Data.String import Data.Text.Encoding (encodeUtf8) import Faktory.Connection newtype Queue = Queue Text deriving stock (Queue -> Queue -> Bool forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Queue -> Queue -> Bool $c/= :: Queue -> Queue -> Bool == :: Queue -> Queue -> Bool $c== :: Queue -> Queue -> Bool Eq, Int -> Queue -> ShowS [Queue] -> ShowS Queue -> String forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Queue] -> ShowS $cshowList :: [Queue] -> ShowS show :: Queue -> String $cshow :: Queue -> String showsPrec :: Int -> Queue -> ShowS $cshowsPrec :: Int -> Queue -> ShowS Show) deriving newtype (String -> Queue forall a. (String -> a) -> IsString a fromString :: String -> Queue $cfromString :: String -> Queue IsString, Value -> Parser [Queue] Value -> Parser Queue forall a. (Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a parseJSONList :: Value -> Parser [Queue] $cparseJSONList :: Value -> Parser [Queue] parseJSON :: Value -> Parser Queue $cparseJSON :: Value -> Parser Queue FromJSON, [Queue] -> Encoding [Queue] -> Value Queue -> Encoding Queue -> Value forall a. (a -> Value) -> (a -> Encoding) -> ([a] -> Value) -> ([a] -> Encoding) -> ToJSON a toEncodingList :: [Queue] -> Encoding $ctoEncodingList :: [Queue] -> Encoding toJSONList :: [Queue] -> Value $ctoJSONList :: [Queue] -> Value toEncoding :: Queue -> Encoding $ctoEncoding :: Queue -> Encoding toJSON :: Queue -> Value $ctoJSON :: Queue -> Value ToJSON) namespaceQueue :: Namespace -> Queue -> Queue namespaceQueue :: Namespace -> Queue -> Queue namespaceQueue (Namespace Text n) (Queue Text q) = Text -> Queue Queue forall a b. (a -> b) -> a -> b $ forall a. Monoid a => a -> a -> a mappend Text n Text q queueArg :: Queue -> ByteString queueArg :: Queue -> ByteString queueArg (Queue Text q) = ByteString -> ByteString fromStrict forall a b. (a -> b) -> a -> b $ Text -> ByteString encodeUtf8 Text q defaultQueue :: Queue defaultQueue :: Queue defaultQueue = Queue "default"