2016-06-08 14:38:01 -05:00
|
|
|
{-# LANGUAGE LambdaCase #-}
|
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2016-06-06 12:54:43 -05:00
|
|
|
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
|
|
|
|
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
|
2016-06-03 10:34:09 -07:00
|
|
|
|
2016-06-06 12:54:43 -05:00
|
|
|
import Control.Monad
|
|
|
|
import Network.GRPC.LowLevel
|
2016-06-08 14:38:01 -05:00
|
|
|
import qualified Network.GRPC.LowLevel.Client.Unregistered as U
|
2016-06-03 10:34:09 -07:00
|
|
|
|
|
|
|
echoMethod = MethodName "/echo.Echo/DoEcho"
|
|
|
|
|
2016-06-06 12:54:43 -05:00
|
|
|
unregistered c = do
|
2016-06-08 14:38:01 -05:00
|
|
|
U.clientRequest c echoMethod 1 "hi" mempty
|
2016-06-03 10:34:09 -07:00
|
|
|
|
2016-06-06 12:54:43 -05:00
|
|
|
registered c = do
|
|
|
|
meth <- clientRegisterMethod c echoMethod Normal
|
2016-06-08 14:38:01 -05:00
|
|
|
clientRequest c meth 1 "hi" mempty
|
2016-06-03 10:34:09 -07:00
|
|
|
|
2016-06-22 13:07:38 -07:00
|
|
|
run f = withGRPC $ \g -> withClient g (ClientConfig "localhost" 50051 []) $ \c ->
|
2016-06-06 12:54:43 -05:00
|
|
|
f c >>= \case
|
|
|
|
Left e -> error $ "Got client error: " ++ show e
|
|
|
|
_ -> return ()
|
2016-06-03 10:34:09 -07:00
|
|
|
|
2016-06-06 12:54:43 -05:00
|
|
|
main = replicateM_ 100 $ run $
|
|
|
|
registered
|