2016-06-08 21:38:01 +02:00
|
|
|
{-# LANGUAGE LambdaCase #-}
|
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2016-06-06 19:54:43 +02:00
|
|
|
{-# 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-08 21:38:01 +02:00
|
|
|
import qualified Network.GRPC.LowLevel.Client.Unregistered as U
|
2016-06-03 19:34:09 +02:00
|
|
|
|
|
|
|
echoMethod = MethodName "/echo.Echo/DoEcho"
|
|
|
|
|
2016-06-06 19:54:43 +02:00
|
|
|
unregistered c = do
|
2016-06-08 21:38:01 +02:00
|
|
|
U.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
|
2016-06-08 21:38:01 +02:00
|
|
|
clientRequest c meth 1 "hi" mempty
|
2016-06-03 19:34:09 +02:00
|
|
|
|
2016-06-22 22:07:38 +02:00
|
|
|
run f = withGRPC $ \g -> withClient g (ClientConfig "localhost" 50051 []) $ \c ->
|
2016-06-06 19:54:43 +02:00
|
|
|
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
|