2016-06-06 19:54:43 +02:00
|
|
|
{-# LANGUAGE LambdaCase #-}
|
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
|
|
|
|
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
|
2016-06-03 19:34:09 +02:00
|
|
|
|
2016-06-06 19:54:43 +02:00
|
|
|
import Control.Monad
|
|
|
|
import Network.GRPC.LowLevel
|
2016-06-03 19:34:09 +02:00
|
|
|
|
|
|
|
echoMethod = MethodName "/echo.Echo/DoEcho"
|
|
|
|
|
2016-06-06 19:54:43 +02:00
|
|
|
unregistered c = do
|
|
|
|
clientRequest c echoMethod 1 "hi" mempty
|
2016-06-03 19:34:09 +02:00
|
|
|
|
2016-06-06 19:54:43 +02:00
|
|
|
registered c = do
|
|
|
|
meth <- clientRegisterMethod c echoMethod Normal
|
|
|
|
clientRegisteredRequest c meth 1 "hi" mempty
|
2016-06-03 19:34:09 +02:00
|
|
|
|
2016-06-06 19:54:43 +02:00
|
|
|
run f = withGRPC $ \g -> withClient g (ClientConfig "localhost" 50051) $ \c ->
|
|
|
|
f c >>= \case
|
|
|
|
Left e -> error $ "Got client error: " ++ show e
|
|
|
|
_ -> return ()
|
2016-06-03 19:34:09 +02:00
|
|
|
|
2016-06-06 19:54:43 +02:00
|
|
|
main = replicateM_ 100 $ run $
|
|
|
|
registered
|