mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-11-27 05:29:43 +01:00
remove duplicated threadDelaySecs function (#56)
This commit is contained in:
parent
d1bc87daa6
commit
bf4166e618
3 changed files with 3 additions and 9 deletions
|
@ -18,6 +18,7 @@ import GHC.Generics (Generic)
|
||||||
import Network.GRPC.HighLevel.Server hiding (serverLoop)
|
import Network.GRPC.HighLevel.Server hiding (serverLoop)
|
||||||
import Network.GRPC.HighLevel.Server.Unregistered (serverLoop)
|
import Network.GRPC.HighLevel.Server.Unregistered (serverLoop)
|
||||||
import Network.GRPC.LowLevel
|
import Network.GRPC.LowLevel
|
||||||
|
import Network.GRPC.LowLevel.GRPC (threadDelaySecs)
|
||||||
import System.Random (randomRIO)
|
import System.Random (randomRIO)
|
||||||
|
|
||||||
data AddRequest = AddRequest {addX :: Fixed Word32
|
data AddRequest = AddRequest {addX :: Fixed Word32
|
||||||
|
@ -94,9 +95,6 @@ serverOpts =
|
||||||
, optServerStreamHandlers = [addServerStreamHandler]
|
, optServerStreamHandlers = [addServerStreamHandler]
|
||||||
, optBiDiStreamHandlers = [addBiDiHandler]}
|
, optBiDiStreamHandlers = [addBiDiHandler]}
|
||||||
|
|
||||||
threadDelaySecs :: Int -> IO ()
|
|
||||||
threadDelaySecs = threadDelay . (* 10^(6::Int))
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = bracket startServer stopServer $ const $ withGRPC $ \grpc ->
|
main = bracket startServer stopServer $ const $ withGRPC $ \grpc ->
|
||||||
withClient grpc (ClientConfig "localhost" 50051 []) $ \c -> do
|
withClient grpc (ClientConfig "localhost" 50051 []) $ \c -> do
|
||||||
|
|
|
@ -21,6 +21,7 @@ import Data.ByteString (ByteString,
|
||||||
isSuffixOf)
|
isSuffixOf)
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Network.GRPC.LowLevel
|
import Network.GRPC.LowLevel
|
||||||
|
import Network.GRPC.LowLevel.GRPC (threadDelaySecs)
|
||||||
import qualified Network.GRPC.LowLevel.Call.Unregistered as U
|
import qualified Network.GRPC.LowLevel.Call.Unregistered as U
|
||||||
import qualified Network.GRPC.LowLevel.Client.Unregistered as U
|
import qualified Network.GRPC.LowLevel.Client.Unregistered as U
|
||||||
import qualified Network.GRPC.LowLevel.Server.Unregistered as U
|
import qualified Network.GRPC.LowLevel.Server.Unregistered as U
|
||||||
|
@ -609,9 +610,6 @@ serverConf (ns, cs, ss, bs) =
|
||||||
methodsToRegisterServerStreaming = ss,
|
methodsToRegisterServerStreaming = ss,
|
||||||
methodsToRegisterBiDiStreaming = bs}
|
methodsToRegisterBiDiStreaming = bs}
|
||||||
|
|
||||||
threadDelaySecs :: Int -> IO ()
|
|
||||||
threadDelaySecs = threadDelay . (* 10^(6::Int))
|
|
||||||
|
|
||||||
mgdGRPC :: Managed GRPC
|
mgdGRPC :: Managed GRPC
|
||||||
mgdGRPC = managed withGRPC
|
mgdGRPC = managed withGRPC
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import Control.Monad
|
||||||
import qualified Data.ByteString as B
|
import qualified Data.ByteString as B
|
||||||
import Foreign.Marshal.Alloc
|
import Foreign.Marshal.Alloc
|
||||||
import Foreign.Storable
|
import Foreign.Storable
|
||||||
|
import Network.GRPC.LowLevel.GRPC (threadDelaySecs)
|
||||||
import Network.GRPC.Unsafe
|
import Network.GRPC.Unsafe
|
||||||
import Network.GRPC.Unsafe.ByteBuffer
|
import Network.GRPC.Unsafe.ByteBuffer
|
||||||
import Network.GRPC.Unsafe.Metadata
|
import Network.GRPC.Unsafe.Metadata
|
||||||
|
@ -126,8 +127,5 @@ assertCqEventComplete e = do
|
||||||
grpc :: IO a -> IO ()
|
grpc :: IO a -> IO ()
|
||||||
grpc = bracket_ grpcInit grpcShutdown . void
|
grpc = bracket_ grpcInit grpcShutdown . void
|
||||||
|
|
||||||
threadDelaySecs :: Int -> IO ()
|
|
||||||
threadDelaySecs = threadDelay . (* 10^(6::Int))
|
|
||||||
|
|
||||||
_nowarnUnused :: a
|
_nowarnUnused :: a
|
||||||
_nowarnUnused = assertCqEventComplete `undefined` threadDelaySecs
|
_nowarnUnused = assertCqEventComplete `undefined` threadDelaySecs
|
||||||
|
|
Loading…
Reference in a new issue