Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Key a msg = Key [Binding]
- data Binding
- data Routing
- key :: Text -> Key Routing msg
- word :: Text -> Key a msg -> Key a msg
- any1 :: Key a msg -> Key Binding msg
- many :: Key a msg -> Key Binding msg
- keyText :: Key a msg -> Text
- fromBind :: Binding -> Text
- toBind :: Text -> Binding
- toBindingKey :: Key a msg -> Key Binding msg
- type family RequireRouting (a :: Type) :: Constraint where ...
Documentation
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
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
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
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 = () |