lxd-client 0.1.0.1 → 0.1.0.2
raw patch · 6 files changed
+51/−14 lines, 6 filesdep ~turtledep ~websocketsPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
Dependency ranges changed: turtle, websockets
API changes (from Hackage documentation)
+ Network.LXD.Client.Internal.Compatibility: class Compatibility a b | a -> b
+ Network.LXD.Client.Internal.Compatibility: compat :: Compatibility a b => a -> b
+ Network.LXD.Client.Internal.Compatibility.WebSockets: Binary :: ByteString -> DataMessage
+ Network.LXD.Client.Internal.Compatibility.WebSockets: Text :: ByteString -> DataMessage
+ Network.LXD.Client.Internal.Compatibility.WebSockets: data DataMessage
+ Network.LXD.Client.Internal.Compatibility.WebSockets: instance GHC.Classes.Eq Network.LXD.Client.Internal.Compatibility.WebSockets.DataMessage
+ Network.LXD.Client.Internal.Compatibility.WebSockets: instance GHC.Show.Show Network.LXD.Client.Internal.Compatibility.WebSockets.DataMessage
+ Network.LXD.Client.Internal.Compatibility.WebSockets: instance Network.LXD.Client.Internal.Compatibility.Compatibility Network.WebSockets.Types.DataMessage Network.LXD.Client.Internal.Compatibility.WebSockets.DataMessage
Files
- lxd-client.cabal +5/−3
- src/Network/LXD/Client.hs +2/−2
- src/Network/LXD/Client/API.hs +8/−5
- src/Network/LXD/Client/Events.hs +6/−4
- src/Network/LXD/Client/Internal/Compatibility.hs +5/−0
- src/Network/LXD/Client/Internal/Compatibility/WebSockets.hs +25/−0
lxd-client.cabal view
@@ -1,5 +1,5 @@ name: lxd-client-version: 0.1.0.1+version: 0.1.0.2 synopsis: LXD client written in Haskell. description: Implementation of the LXD client protocol in Haskell.@@ -29,6 +29,8 @@ , Network.LXD.Client.API , Network.LXD.Client.Commands , Network.LXD.Client.Events+ , Network.LXD.Client.Internal.Compatibility+ , Network.LXD.Client.Internal.Compatibility.WebSockets , Network.LXD.Client.Internal.Prelude , Network.LXD.Client.Remotes , Network.LXD.Client.Types@@ -58,7 +60,7 @@ , tls >= 1.3.9 && <2 , transformers >= 0.5.2.0 && <1 , unix >= 2.7.0.1 && <3- , websockets >= 0.10.0.0 && <0.11+ , websockets >= 0.10.0.0 && <0.11 || >= 0.12.2.0 && <0.13 , x509 >= 1.6.5 && <2 , x509-store >= 1.6.2 && <2 , x509-validation >= 1.6.5 && <2@@ -86,7 +88,7 @@ , hspec-core >= 2.4.4 && <3 , random >= 1.1 && <2 , text- , turtle >= 1.3.6 && <1.4+ , turtle >= 1.3.6 && <1.5 , uuid >= 1.3.13 && <2 ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall default-extensions: NoImplicitPrelude OverloadedStrings
src/Network/LXD/Client.hs view
@@ -63,7 +63,7 @@ Supported(supportedCiphers), credentialLoadX509, defaultParamsClient)-import Network.TLS.Extra.Cipher (ciphersuite_all)+import Network.TLS.Extra.Cipher (ciphersuite_default) import qualified Network.Connection as Con import qualified Network.Socket as Socket import qualified Network.WebSockets as WS@@ -171,7 +171,7 @@ clientParams = (defaultParamsClient host "") { clientShared = shared , clientHooks = hooks- , clientSupported = def { supportedCiphers = ciphersuite_all }+ , clientSupported = def { supportedCiphers = ciphersuite_default } } shared | Just store <- caStore = def { sharedCAStore = store } | otherwise = def
src/Network/LXD/Client/API.hs view
@@ -123,7 +123,10 @@ import Web.HttpApiData (FromHttpApiData, ToHttpApiData, toHeader, parseHeader) import Network.LXD.Client.Types+import Network.LXD.Client.Internal.Compatibility (compat)+import qualified Network.LXD.Client.Internal.Compatibility.WebSockets as WSC + type API = Get '[JSON] (Response [ApiVersion]) :<|> "1.0" :> Get '[JSON] (Response ApiConfig) :<|> "1.0" :> "certificates" :> Get '[JSON] (Response [CertificateHash])@@ -362,11 +365,11 @@ readAllWebSocket :: (ByteString -> IO ()) -> WS.ClientApp () readAllWebSocket f con = do- m <- (Just <$> WS.receiveDataMessage con) `catch` handle'- case m of Nothing -> return ()- Just (WS.Text _) -> WS.sendClose con BL.empty- Just (WS.Binary bs) -> f bs- >> readAllWebSocket f con+ m <- (Just . compat <$> WS.receiveDataMessage con) `catch` handle'+ case m of Nothing -> return ()+ Just (WSC.Text _) -> WS.sendClose con BL.empty+ Just (WSC.Binary bs) -> f bs+ >> readAllWebSocket f con where handle' (WS.CloseRequest _ _) = return Nothing handle' e = throwIO e
src/Network/LXD/Client/Events.hs view
@@ -18,6 +18,8 @@ import Web.Internal.HttpApiData (ToHttpApiData(..)) import Network.LXD.Client.Types+import Network.LXD.Client.Internal.Compatibility (compat)+import qualified Network.LXD.Client.Internal.Compatibility.WebSockets as WSC eventsPath :: [EventType] -> String eventsPath types = "/1.0/events?" ++ typesQuery@@ -34,10 +36,10 @@ go `finally` WS.sendClose con BL.empty where go = do- m <- (Just <$> WS.receiveDataMessage con) `catch` handle'- case m of Nothing -> f Nothing- Just (WS.Text t) -> decodeMsg t >>= f . Just >> go- Just (WS.Binary b) -> decodeMsg b >>= f . Just >> go+ m <- (Just . compat <$> WS.receiveDataMessage con) `catch` handle'+ case m of Nothing -> f Nothing+ Just (WSC.Text t) -> decodeMsg t >>= f . Just >> go+ Just (WSC.Binary b) -> decodeMsg b >>= f . Just >> go handle' (WS.CloseRequest _ _) = return Nothing handle' e = throwIO e
+ src/Network/LXD/Client/Internal/Compatibility.hs view
@@ -0,0 +1,5 @@+{-# LANGUAGE FunctionalDependencies #-}+module Network.LXD.Client.Internal.Compatibility where++class Compatibility a b | a -> b where+ compat :: a -> b
+ src/Network/LXD/Client/Internal/Compatibility/WebSockets.hs view
@@ -0,0 +1,25 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+module Network.LXD.Client.Internal.Compatibility.WebSockets where++import Network.LXD.Client.Internal.Prelude++import Data.ByteString.Lazy (ByteString)++import qualified Network.WebSockets as WS++import Network.LXD.Client.Internal.Compatibility (Compatibility(..))++data DataMessage = Text ByteString+ | Binary ByteString+ deriving (Eq, Show)++instance Compatibility WS.DataMessage DataMessage where+#if MIN_VERSION_websockets(0, 11, 0)+ compat (WS.Text v _) = Text v+ compat (WS.Binary v) = Binary v+#else+ compat (WS.Text v) = Text v+ compat (WS.Binary v) = Binary v+#endif