@@ -2,11 +2,73 @@
3Curryer (pun intended) is a fast, Haskell-exclusive RPC (remote procedure call) library. By using the latest Haskell serialization and streaming libraries, curryer aims to be the fastest and easiest means of communicating between Haskell-based processes.
3Curryer (pun intended) is a fast, Haskell-exclusive RPC (remote procedure call) library. By using the latest Haskell serialization and streaming libraries, curryer aims to be the fastest and easiest means of communicating between Haskell-based processes.
5−Curryer is inspired by the now unmaintained [distributed-process](https://hackage.haskell.org/package/distributed-process) library.
5+Curryer is inspired by the now unmaintained [distributed-process](https://hackage.haskell.org/package/distributed-process) library, but is lighter-weight and uses a higher-performance serialization package.
9* blocking and non-blocking remote function calls
9* blocking and non-blocking remote function calls
10* asynchronous server-to-client callbacks (for server-initiated notifications)
10* asynchronous server-to-client callbacks (for server-initiated notifications)
12−* utilizes versionable shared ADT for communication instead of shared function `StaticPtr`s
12+* leverages [winery](https://hackage.haskell.org/package/winery) for high-performance serialization
16+[Server](https://github.com/agentm/curryer/examples/SimpleKeyValueServer.hs):
19+data SetKey = SetKey String String
20+ deriving (Generic, Show)
21+ deriving Serialise via WineryVariant SetKey
23+data GetKey = GetKey String
24+ deriving (Generic, Show)
25+ deriving Serialise via WineryVariant GetKey
30+ void $ serve kvRequestHandlers kvmap localHostAddr 8765 Nothing
32+kvRequestHandlers :: RequestHandlers (M.Map String String)
33+kvRequestHandlers = [ RequestHandler $ \state (SetKey k v) ->
34+ atomically $ M.insert v k (connectionServerState state)
35+ , RequestHandler $ \state (GetKey k) ->
36+ atomically $ M.lookup k (connectionServerState state)
40+[Client](https://github.com/agentm/curryer/examples/SimpleKeyValueClient.hs):
43+data SetKey = SetKey String String
44+ deriving (Generic, Show)
45+ deriving Serialise via WineryVariant SetKey
47+data GetKey = GetKey String
48+ deriving (Generic, Show)
49+ deriving Serialise via WineryVariant GetKey
51+data CommandOptions = Get {name :: String}
52+ | Set {name :: String, value :: String}
53+ deriving (Generic, Show)
55+instance ParseRecord CommandOptions
59+ opts <- getRecord "SimpleKeyValueClient"
60+ conn <- connect [] localHostAddr 8765
63+ eRet <- call conn (GetKey k)
65+ Left err -> error (show err)
66+ Right (Just val) -> putStrLn val
67+ Right Nothing -> error "no such key"
69+ eRet <- call conn (SetKey k v)
71+ Left err -> error (show err)