Safe Haskell | None |
---|---|
Language | Haskell2010 |
- newtype Path = Path [Text]
- type ReferenceCount = Int
- type Revision = Int
- type ResourceStatusMap = Map Path (TVar (RefCounted ResourceStatus))
- data ResourceStatus
- data RefCounted a = RefCounted {
- refCount :: ReferenceCount
- refValue :: a
- type LogRunner = forall m a. MonadIO m => LoggingT m a -> m a
- data Subscriber api = Subscriber {
- subState :: !(TVar ResourceStatusMap)
- entryPoint :: !Path
- runLogging :: LogRunner
- data Event
- notify :: forall api endpoint. (IsElem endpoint api, HasLink endpoint, IsValidEndpoint endpoint, IsSubscribable endpoint api) => Subscriber api -> Event -> Proxy endpoint -> (MkLink endpoint -> URI) -> STM ()
- notifyIO :: forall api endpoint. (IsElem endpoint api, HasLink endpoint, IsValidEndpoint endpoint, IsSubscribable endpoint api) => Subscriber api -> Event -> Proxy endpoint -> (MkLink endpoint -> URI) -> IO ()
- subscribe :: Path -> Subscriber api -> STM (TVar (RefCounted ResourceStatus))
- unsubscribe :: Path -> TVar (RefCounted ResourceStatus) -> Subscriber api -> STM ()
- modifyState :: Event -> Path -> Subscriber api -> STM ()
- eventHandler :: Event -> ResourceStatus -> ResourceStatus
- doDelete :: ResourceStatus -> ResourceStatus
- doModify :: ResourceStatus -> ResourceStatus
- toSegments :: Path -> [Text]
Documentation
type ReferenceCount = Int Source #
type ResourceStatusMap = Map Path (TVar (RefCounted ResourceStatus)) Source #
data ResourceStatus Source #
data RefCounted a Source #
RefCounted | |
|
data Subscriber api Source #
Subscriber | |
|
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.
eventHandler :: Event -> ResourceStatus -> ResourceStatus Source #
toSegments :: Path -> [Text] Source #