packages feed

servant-subscriber 0.5.0.1 → 0.5.0.2

raw patch · 5 files changed

+31/−20 lines, 5 files

Files

servant-subscriber.cabal view
@@ -1,5 +1,5 @@ name:                servant-subscriber-version:             0.5.0.1+version:             0.5.0.2 synopsis:            When REST is not enough ... description:         Please see Readme.md homepage:            http://github.com/eskimor/servant-subscriber#readme
src/Servant/Subscriber/Client.hs view
@@ -40,7 +40,7 @@   , readRequest     :: !(IO (Maybe Request))   , writeResponse   :: !(Response -> IO ())   , pongCommandRef  :: !(IORef (IO ()))-  , closeCommandRef :: !(TVar (IO ())) -- |< TVar so actions on it can happen in STM+  , closeCommandRef :: !(TVar (IO ())) -- TVar so actions on it can happen in STM   }  data StatusMonitor = StatusMonitor {@@ -193,7 +193,7 @@  handleUpdates :: Backend backend => backend -> Client api -> (Set HttpRequest, ResourceStatus) -> IO () handleUpdates b c (reqs, event) = case event of-    S.Deleted        -> writeResponse c $ Resp.Deleted (httpPath . Set.elemAt 0 $ reqs) -- |< elemAt is partial - but we should never have an empty set, so this should be fine! - Check, check double check - test suite?! Or change parameters to this function.+    S.Deleted        -> writeResponse c $ Resp.Deleted (httpPath . Set.elemAt 0 $ reqs) -- elemAt is partial - but we should never have an empty set, so this should be fine! - Check, check double check - test suite?! Or change parameters to this function.     ( S.Modified _ ) -> mapM_ (handleModified b c) reqs  
src/Servant/Subscriber/Request.hs view
@@ -17,24 +17,25 @@   -{--| We don't use Network.HTTP.Types here, because we need FromJSON instances, which can not-     be derived for 'ByteString'---}+--   We don't use Network.HTTP.Types here, because we need FromJSON instances, which can not+--   be derived for 'ByteString' type RequestHeader = (Text, Text) type RequestHeaders = [RequestHeader]  -- | Any message from the client is a 'Request':-data Request =-    Subscribe !HttpRequest-  | Unsubscribe !HttpRequest--- | A request that should be issued whenever a websocket pong is received.+--+--   `SetPongRequest`: A request that should be issued whenever a websocket pong is received. --   In addition to every websocket pong the request also gets issued --   immediately upon receival. Bot `SetPongRequest` and `SetCloseRequest` will --   be confirmed with a `Subscribed` response, but any return value of the --   request won't be delivered.-  | SetPongRequest !HttpRequest-  | SetCloseRequest !HttpRequest -- |< A request that should be issued when the websocket connection closes for whatever reason.-  deriving Generic+--+--   `SetCloseRequest`: A request that should be issued when the websocket+--   connection closes for whatever reason.+data Request = Subscribe !HttpRequest+             | Unsubscribe !HttpRequest+             | SetPongRequest !HttpRequest+             | SetCloseRequest !HttpRequest deriving (Generic)  instance FromJSON Request instance ToJSON Request@@ -62,7 +63,7 @@ toHTTPHeaders :: RequestHeaders -> H.RequestHeaders toHTTPHeaders = map toHTTPHeader --- | This is ugly - but I don't care for now.+-- This is ugly - but I don't care for now. requestPath :: Request -> Path requestPath req = httpPath $ case req of                     Subscribe hReq -> hReq
src/Servant/Subscriber/Response.hs view
@@ -27,13 +27,23 @@ type ResponseHeaders = R.RequestHeaders  -- | Any message from the server is a Response.+--+--   'Subscribed': Resource was successfully subscribed+--+--   'Modified': Resource was modified (this message is also triggered immediately after a subscription)+--+--   'HttpRequestFailed': The server replied with some none 2xx status code.+--   Thus your subscription failed or got removed.+--+--   'ParseError': Your request could not be parsed.+ data Response =-    Subscribed !R.HttpRequest -- |< Resource was successfully subscribed-  | Modified !R.HttpRequest !ResponseBody -- |< If the full response is needed an additional FullSubscribe command with an appropriate additional response type will need to be added. +    Subscribed !R.HttpRequest+  | Modified !R.HttpRequest !ResponseBody -- If the full response is needed an additional FullSubscribe command with an appropriate additional response type will need to be added.   | Deleted !Path   | Unsubscribed !R.HttpRequest-  | HttpRequestFailed !R.HttpRequest !HttpResponse -- |< The server replied with some none 2xx status code. Thus your subscription failed.-  | ParseError -- |< Your request could not be parsed.+  | HttpRequestFailed !R.HttpRequest !HttpResponse+  | ParseError   deriving Generic  instance ToJSON Response
src/Servant/Subscriber/Types.hs view
@@ -69,7 +69,7 @@  data Event = DeleteEvent | ModifyEvent deriving (Eq) -{--|+{-|   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.@@ -81,7 +81,7 @@   for: You will typicall provide a lamda there providing needed parameters.    TODO: Example!---}+-} notify :: forall api endpoint. (IsElem endpoint api, HasLink endpoint   , IsValidEndpoint endpoint, IsSubscribable endpoint api)   => Subscriber api