amqp-worker-2.0.0: Type-safe AMQP workers
Safe HaskellSafe-Inferred
LanguageHaskell2010

Network.AMQP.Worker.Key

Synopsis

Documentation

newtype Key a msg Source #

Messages are published with a specific identifier called a Routing key. Queues can use Binding Keys to control which messages are delivered to them.

Routing keys have no dynamic component and can be used to publish messages

commentsKey :: Key Route Comment
commentsKey = key "posts" & word "new"

Binding keys can contain wildcards, only used for matching messages

commentsKey :: Key Bind Comment
commentsKey = key "posts" & any1 & word "comments" & many

Constructors

Key [Bind] 

Instances

Instances details
Monoid (Key a msg) Source # 
Instance details

Defined in Network.AMQP.Worker.Key

Methods

mempty :: Key a msg #

mappend :: Key a msg -> Key a msg -> Key a msg #

mconcat :: [Key a msg] -> Key a msg #

Semigroup (Key a msg) Source # 
Instance details

Defined in Network.AMQP.Worker.Key

Methods

(<>) :: Key a msg -> Key a msg -> Key a msg #

sconcat :: NonEmpty (Key a msg) -> Key a msg #

stimes :: Integral b => b -> Key a msg -> Key a msg #

Show (Key a msg) Source # 
Instance details

Defined in Network.AMQP.Worker.Key

Methods

showsPrec :: Int -> Key a msg -> ShowS #

show :: Key a msg -> String #

showList :: [Key a msg] -> ShowS #

Eq (Key a msg) Source # 
Instance details

Defined in Network.AMQP.Worker.Key

Methods

(==) :: Key a msg -> Key a msg -> Bool #

(/=) :: Key a msg -> Key a msg -> Bool #

data Bind Source #

Constructors

Word Text 
Any 
Many 

Instances

Instances details
Show Bind Source # 
Instance details

Defined in Network.AMQP.Worker.Key

Methods

showsPrec :: Int -> Bind -> ShowS #

show :: Bind -> String #

showList :: [Bind] -> ShowS #

Eq Bind Source # 
Instance details

Defined in Network.AMQP.Worker.Key

Methods

(==) :: Bind -> Bind -> Bool #

(/=) :: Bind -> Bind -> Bool #

key :: Text -> Key Route msg Source #

Start a new routing key (can also be used for bindings)

key "messages"
-- matches "messages"

word :: Text -> Key a msg -> Key a msg Source #

A specific word. Can be used to chain Routing keys or Binding keys

key "messages" & word "new"
-- matches "messages.new"

any1 :: Key a msg -> Key Bind msg Source #

Match any one word. Equivalent to *. Converts to a Binding key and can no longer be used to publish messaages

key "messages" & any1
-- matches "messages.new"
-- matches "messages.update"

many :: Key a msg -> Key Bind msg Source #

Match zero or more words. Equivalient to #. Converts to a Binding key and can no longer be used to publish messages

key "messages" & many
-- matches "messages"
-- matches "messages.new"
-- matches "messages.1234.update"

keyText :: Key a msg -> Text Source #

toBindKey :: Key a msg -> Key Bind msg Source #

We can convert Route Keys to Bind Keys safely, as they are usable for both publishing and binding

type family RequireRoute (a :: Type) :: Constraint where ... Source #

Custom error message when trying to publish to Binding keys

Equations

RequireRoute Bind = TypeError ('Text "Expected Routing Key but got Binding Key instead. Messages can be published only with keys that exclusivlely use `key` and `word`" :$$: 'Text "\n key \"message\" & word \"new\" \n") 
RequireRoute a = ()