Some haddock docs.
diff --git a/Network/YAML/Balancer.hs b/Network/YAML/Balancer.hs
index 4c05fbe..bcef59a 100644
--- a/Network/YAML/Balancer.hs
+++ b/Network/YAML/Balancer.hs
@@ -4,12 +4,12 @@ module Network.YAML.Balancer where
import System.Random
import qualified Data.ByteString.Char8 as BS
-type Server = (BS.ByteString, Int)
+import Network.YAML.Base (HostAndPort)
-- | Select random server
-selectRandom :: [(BS.ByteString, Server, Int)] -- ^ [(Service name, (hostname, port number), priority)]
- -> BS.ByteString -- ^ Service name
- -> IO Server
+selectRandom :: [(BS.ByteString, HostAndPort, Int)] -- ^ [(Service name, (hostname, port number), priority)]
+ -> BS.ByteString -- ^ Service name
+ -> IO HostAndPort
selectRandom lst service = do
let lst' = concatMap (\(name,srv,p) -> replicate p (name, srv)) lst
lst'' = map snd $ filter (\(name,srv) -> name==service) lst'
diff --git a/Network/YAML/Caller.hs b/Network/YAML/Caller.hs
index f035072..dcaad0c 100644
--- a/Network/YAML/Caller.hs
+++ b/Network/YAML/Caller.hs
@@ -18,7 +18,7 @@ import Network.YAML.Server
class Connection c where
newConnection :: (BS.ByteString, Int) -> IO c
closeConnection :: c -> IO ()
--- | Call remote method
+ -- | Call remote method
call :: (IsYamlObject a, IsYamlObject b)
=> c
-> BS.ByteString -- ^ Name of method
@@ -84,7 +84,7 @@ instance Connection PersistentConnection where
Nothing -> fail "No answer"
Just x -> return x
--- | Similar, but select server on each call
+-- | Similar to call, but select server on each call
callDynamic :: (IsYamlObject a, IsYamlObject b)
=> (BS.ByteString -> IO (BS.ByteString,Int)) -- ^ Get (Host name, port number) from service name
-> BS.ByteString -- ^ Name of the service
diff --git a/Network/YAML/Server.hs b/Network/YAML/Server.hs
index 3366276..2b9bb84 100644
--- a/Network/YAML/Server.hs
+++ b/Network/YAML/Server.hs
@@ -46,7 +46,9 @@ readHandle h acc = do
then return acc
else readHandle h (acc ++ [line'])
--- | Start server and wait for connections
+-- | Start server and wait for connections.
+-- This server closes connection after each query.
+-- So, each call is processed in another thread.
server ::
Int -- ^ Port number
-> (YamlObject -> IO YamlObject) -- ^ Worker
@@ -72,6 +74,9 @@ server port callOut = do
BS.hPutStrLn h $ serialize res
hClose h)
+-- | Start server and wait for connections.
+-- This server does not close connection after query.
+-- So, new thread is created only per-client, not per-query.
persistentServer ::
Int
-> (YamlObject -> IO YamlObject)
diff --git a/Network/YAML/WrapMethods.hs b/Network/YAML/WrapMethods.hs
index 7adb28c..5129597 100644
--- a/Network/YAML/WrapMethods.hs
+++ b/Network/YAML/WrapMethods.hs
@@ -31,6 +31,9 @@ remote name = do
sigD cName [t| (Connection c) => c -> $(return a) -> $(return ioB) |],
funD cName [c]]
+-- | Similar to remote, but use it when basic function accepts additional argument,
+-- which should not be passed from client.
+-- (To be used in pair with declareRulesWithArg).
remote' :: Name -> Q [Dec]
remote' name = do
srv <- newName "srv"