amqp-worker-1.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 Routing Comment
commentsKey = key "posts" & word "new"

Binding keys can contain wildcards, only used for matching messages

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

Constructors

Key [Binding] 

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 Binding Source #

Constructors

Word Text 
Any 
Many 

Instances

Instances details
Show Binding Source # 
Instance details

Defined in Network.AMQP.Worker.Key

Eq Binding Source # 
Instance details

Defined in Network.AMQP.Worker.Key

Methods

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

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

key :: Text -> Key Routing msg Source #

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

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

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

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

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

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

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

keyText :: Key a msg -> Text Source #

toBindingKey :: Key a msg -> Key Binding msg Source #

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

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

Custom error message when trying to publish to Binding keys

Equations

RequireRouting Binding = 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") 
RequireRouting a = ()