gRPC-haskell/examples/echo/echo-client/Main.hs
Connor Clark a530faf912 Channel options: user agents and compression (#32)
* get_peer: fix todo

* add documentation for server registered call function

* test roundtrip conversion of larger bytestrings (32 mb)

* Add channel args interface: currently supports user agents and compression.

* fix build failure after stack clean
2016-06-22 13:07:38 -07:00

25 lines
742 B
Haskell

{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
import Control.Monad
import Network.GRPC.LowLevel
import qualified Network.GRPC.LowLevel.Client.Unregistered as U
echoMethod = MethodName "/echo.Echo/DoEcho"
unregistered c = do
U.clientRequest c echoMethod 1 "hi" mempty
registered c = do
meth <- clientRegisterMethod c echoMethod Normal
clientRequest c meth 1 "hi" mempty
run f = withGRPC $ \g -> withClient g (ClientConfig "localhost" 50051 []) $ \c ->
f c >>= \case
Left e -> error $ "Got client error: " ++ show e
_ -> return ()
main = replicateM_ 100 $ run $
registered