servant-subscriber-0.6.0.1: When REST is not enough ...

Safe HaskellNone
LanguageHaskell2010

Servant.Subscriber.Types

Synopsis

Documentation

newtype Path Source #

Constructors

Path [Text] 

Instances

Eq Path Source # 

Methods

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

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

Ord Path Source # 

Methods

compare :: Path -> Path -> Ordering #

(<) :: Path -> Path -> Bool #

(<=) :: Path -> Path -> Bool #

(>) :: Path -> Path -> Bool #

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

max :: Path -> Path -> Path #

min :: Path -> Path -> Path #

Show Path Source # 

Methods

showsPrec :: Int -> Path -> ShowS #

show :: Path -> String #

showList :: [Path] -> ShowS #

IsString Path Source # 

Methods

fromString :: String -> Path #

Generic Path Source # 

Associated Types

type Rep Path :: * -> * #

Methods

from :: Path -> Rep Path x #

to :: Rep Path x -> Path #

ToJSON Path Source # 
FromJSON Path Source # 
type Rep Path Source # 
type Rep Path = D1 (MetaData "Path" "Servant.Subscriber.Types" "servant-subscriber-0.6.0.1-61EPyOtv8bEcXLjl4joX9" True) (C1 (MetaCons "Path" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Text])))

data RefCounted a Source #

Constructors

RefCounted 

Instances

Functor RefCounted Source # 

Methods

fmap :: (a -> b) -> RefCounted a -> RefCounted b #

(<$) :: a -> RefCounted b -> RefCounted a #

type LogRunner = forall m a. MonadIO m => LoggingT m a -> m a Source #

data Event Source #

Constructors

DeleteEvent 
ModifyEvent 

Instances

Eq Event Source # 

Methods

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

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

notify :: forall api endpoint. (IsElem endpoint api, HasLink endpoint, IsValidEndpoint endpoint, IsSubscribable endpoint api) => Subscriber api -> Event -> Proxy endpoint -> (MkLink endpoint -> URI) -> STM () Source #

Notify the subscriber about a changed resource. You have to provide a typesafe link to the changed resource. Only Symbols and Captures are allowed in this link.

You need to provide a proxy to the API too. This is needed to check that the endpoint is valid and points to a Subscribable resource.

One piece is still missing - we have to fill out captures, that's what the getLink parameter is for: You will typicall provide a lamda there providing needed parameters.

TODO: Example!

notifyIO :: forall api endpoint. (IsElem endpoint api, HasLink endpoint, IsValidEndpoint endpoint, IsSubscribable endpoint api) => Subscriber api -> Event -> Proxy endpoint -> (MkLink endpoint -> URI) -> IO () Source #

Version of notify that lives in IO - for your convenience.

subscribe :: Path -> Subscriber api -> STM (TVar (RefCounted ResourceStatus)) Source #

Subscribe to a ResourceStatus - it will be created when not present

unsubscribe :: Path -> TVar (RefCounted ResourceStatus) -> Subscriber api -> STM () Source #

Unget a previously got ResourceState - make sure you match every call to subscribe with a call to unsubscribe!

modifyState :: Event -> Path -> Subscriber api -> STM () Source #

Modify a ResourceState if it is present in the map, otherwise do nothing.