mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-11-04 18:29:42 +01:00
fix all warnings (#35)
This commit is contained in:
parent
9f170be5b0
commit
accc8b8573
10 changed files with 15 additions and 27 deletions
|
@ -124,7 +124,8 @@ test-suite test
|
||||||
hs-source-dirs: tests
|
hs-source-dirs: tests
|
||||||
main-is: Properties.hs
|
main-is: Properties.hs
|
||||||
type: exitcode-stdio-1.0
|
type: exitcode-stdio-1.0
|
||||||
extensions: CPP
|
default-extensions: CPP
|
||||||
|
|
||||||
if flag(debug)
|
if flag(debug)
|
||||||
GHC-Options: -DDEBUG
|
CPP-Options: -DDEBUG
|
||||||
|
CC-Options: -DGRPC_HASKELL_DEBUG
|
||||||
|
|
|
@ -10,14 +10,10 @@ import Control.Monad
|
||||||
import Data.ByteString (ByteString)
|
import Data.ByteString (ByteString)
|
||||||
import Data.String (IsString)
|
import Data.String (IsString)
|
||||||
import Foreign.Marshal.Alloc (free)
|
import Foreign.Marshal.Alloc (free)
|
||||||
import Foreign.Ptr (Ptr, nullPtr)
|
import Foreign.Ptr (Ptr)
|
||||||
import Foreign.Storable (peek)
|
|
||||||
import System.Clock
|
import System.Clock
|
||||||
|
|
||||||
import qualified Network.GRPC.Unsafe as C
|
import qualified Network.GRPC.Unsafe as C
|
||||||
import qualified Network.GRPC.Unsafe.ByteBuffer as C
|
|
||||||
import qualified Network.GRPC.Unsafe.Metadata as C
|
|
||||||
import qualified Network.GRPC.Unsafe.Time as C
|
|
||||||
import qualified Network.GRPC.Unsafe.Op as C
|
import qualified Network.GRPC.Unsafe.Op as C
|
||||||
|
|
||||||
import Network.GRPC.LowLevel.GRPC (MetadataMap, grpcDebug)
|
import Network.GRPC.LowLevel.GRPC (MetadataMap, grpcDebug)
|
||||||
|
|
|
@ -5,13 +5,11 @@ module Network.GRPC.LowLevel.Call.Unregistered where
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Foreign.Marshal.Alloc (free)
|
import Foreign.Marshal.Alloc (free)
|
||||||
import Foreign.Ptr (Ptr)
|
import Foreign.Ptr (Ptr)
|
||||||
import Foreign.Storable (peek)
|
|
||||||
import System.Clock (TimeSpec)
|
import System.Clock (TimeSpec)
|
||||||
|
|
||||||
import Network.GRPC.LowLevel.Call (Host (..), MethodName (..))
|
import Network.GRPC.LowLevel.Call (Host (..), MethodName (..))
|
||||||
import Network.GRPC.LowLevel.GRPC (MetadataMap, grpcDebug)
|
import Network.GRPC.LowLevel.GRPC (MetadataMap, grpcDebug)
|
||||||
import qualified Network.GRPC.Unsafe as C
|
import qualified Network.GRPC.Unsafe as C
|
||||||
import qualified Network.GRPC.Unsafe.Metadata as C
|
|
||||||
import qualified Network.GRPC.Unsafe.Op as C
|
import qualified Network.GRPC.Unsafe.Op as C
|
||||||
|
|
||||||
-- | Represents one unregistered GRPC call on the server.
|
-- | Represents one unregistered GRPC call on the server.
|
||||||
|
|
|
@ -29,7 +29,6 @@ module Network.GRPC.LowLevel.CompletionQueue
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
import Control.Concurrent (forkIO)
|
|
||||||
import Control.Concurrent.STM (atomically, check)
|
import Control.Concurrent.STM (atomically, check)
|
||||||
import Control.Concurrent.STM.TVar (newTVarIO, readTVar,
|
import Control.Concurrent.STM.TVar (newTVarIO, readTVar,
|
||||||
writeTVar)
|
writeTVar)
|
||||||
|
@ -45,15 +44,13 @@ import qualified Network.GRPC.Unsafe.Constants as C
|
||||||
import qualified Network.GRPC.Unsafe.Metadata as C
|
import qualified Network.GRPC.Unsafe.Metadata as C
|
||||||
import qualified Network.GRPC.Unsafe.Op as C
|
import qualified Network.GRPC.Unsafe.Op as C
|
||||||
import qualified Network.GRPC.Unsafe.Time as C
|
import qualified Network.GRPC.Unsafe.Time as C
|
||||||
import System.Clock (getTime, Clock(..),
|
import System.Clock (getTime, Clock(..))
|
||||||
TimeSpec(..))
|
|
||||||
import System.Timeout (timeout)
|
import System.Timeout (timeout)
|
||||||
|
|
||||||
import Network.GRPC.LowLevel.Call
|
import Network.GRPC.LowLevel.Call
|
||||||
import Network.GRPC.LowLevel.GRPC
|
import Network.GRPC.LowLevel.GRPC
|
||||||
import Network.GRPC.LowLevel.CompletionQueue.Internal
|
import Network.GRPC.LowLevel.CompletionQueue.Internal
|
||||||
import qualified Network.GRPC.Unsafe.ByteBuffer as C
|
import qualified Network.GRPC.Unsafe.ByteBuffer as C
|
||||||
import qualified Network.GRPC.Unsafe.Metadata as C
|
|
||||||
|
|
||||||
withCompletionQueue :: GRPC -> (CompletionQueue -> IO a) -> IO a
|
withCompletionQueue :: GRPC -> (CompletionQueue -> IO a) -> IO a
|
||||||
withCompletionQueue grpc = bracket (createCompletionQueue grpc)
|
withCompletionQueue grpc = bracket (createCompletionQueue grpc)
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
module Network.GRPC.LowLevel.CompletionQueue.Unregistered where
|
module Network.GRPC.LowLevel.CompletionQueue.Unregistered where
|
||||||
|
|
||||||
import Control.Concurrent (forkIO)
|
|
||||||
import Control.Exception (bracket)
|
import Control.Exception (bracket)
|
||||||
import Foreign.Marshal.Alloc (free, malloc)
|
import Foreign.Marshal.Alloc (free, malloc)
|
||||||
import Foreign.Storable (peek)
|
import Foreign.Storable (peek)
|
||||||
|
|
|
@ -13,7 +13,6 @@ import Foreign.Marshal.Alloc (free, malloc,
|
||||||
mallocBytes)
|
mallocBytes)
|
||||||
import Foreign.Ptr (Ptr, nullPtr)
|
import Foreign.Ptr (Ptr, nullPtr)
|
||||||
import Foreign.Storable (peek, poke)
|
import Foreign.Storable (peek, poke)
|
||||||
import Network.GRPC.LowLevel.Call
|
|
||||||
import Network.GRPC.LowLevel.CompletionQueue
|
import Network.GRPC.LowLevel.CompletionQueue
|
||||||
import Network.GRPC.LowLevel.GRPC
|
import Network.GRPC.LowLevel.GRPC
|
||||||
import qualified Network.GRPC.Unsafe as C (Call)
|
import qualified Network.GRPC.Unsafe as C (Call)
|
||||||
|
|
|
@ -8,10 +8,8 @@ module Network.GRPC.LowLevel.Server where
|
||||||
import Control.Exception (bracket, finally)
|
import Control.Exception (bracket, finally)
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Data.ByteString (ByteString)
|
import Data.ByteString (ByteString)
|
||||||
import Foreign.Ptr (nullPtr)
|
|
||||||
import Network.GRPC.LowLevel.Call
|
import Network.GRPC.LowLevel.Call
|
||||||
import Network.GRPC.LowLevel.CompletionQueue (CompletionQueue,
|
import Network.GRPC.LowLevel.CompletionQueue (CompletionQueue,
|
||||||
TimeoutSeconds,
|
|
||||||
createCompletionQueue,
|
createCompletionQueue,
|
||||||
pluck,
|
pluck,
|
||||||
serverRegisterCompletionQueue,
|
serverRegisterCompletionQueue,
|
||||||
|
|
|
@ -4,9 +4,7 @@ module Network.GRPC.LowLevel.Server.Unregistered where
|
||||||
|
|
||||||
import Control.Exception (finally)
|
import Control.Exception (finally)
|
||||||
import Data.ByteString (ByteString)
|
import Data.ByteString (ByteString)
|
||||||
import Network.GRPC.LowLevel.Call (MethodName)
|
|
||||||
import Network.GRPC.LowLevel.Call.Unregistered
|
import Network.GRPC.LowLevel.Call.Unregistered
|
||||||
import Network.GRPC.LowLevel.CompletionQueue (TimeoutSeconds)
|
|
||||||
import Network.GRPC.LowLevel.CompletionQueue.Unregistered (serverRequestCall)
|
import Network.GRPC.LowLevel.CompletionQueue.Unregistered (serverRequestCall)
|
||||||
import Network.GRPC.LowLevel.GRPC
|
import Network.GRPC.LowLevel.GRPC
|
||||||
import Network.GRPC.LowLevel.Op (Op(..), OpRecvResult (..), runOps)
|
import Network.GRPC.LowLevel.Op (Op(..), OpRecvResult (..), runOps)
|
||||||
|
|
|
@ -5,7 +5,6 @@ module Network.GRPC.Unsafe.ChannelArgs where
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Foreign.Storable
|
import Foreign.Storable
|
||||||
import Foreign.Ptr (nullPtr)
|
|
||||||
import Foreign.Marshal.Alloc (malloc, free)
|
import Foreign.Marshal.Alloc (malloc, free)
|
||||||
|
|
||||||
#include <grpc/grpc.h>
|
#include <grpc/grpc.h>
|
||||||
|
|
|
@ -5,10 +5,7 @@
|
||||||
module LowLevelTests.Op where
|
module LowLevelTests.Op where
|
||||||
|
|
||||||
import Control.Concurrent (threadDelay)
|
import Control.Concurrent (threadDelay)
|
||||||
import Control.Concurrent.Async
|
import Data.ByteString (isPrefixOf)
|
||||||
import Control.Monad
|
|
||||||
import Data.ByteString (ByteString, isPrefixOf)
|
|
||||||
import qualified Data.Map as M
|
|
||||||
import Foreign.Storable (peek)
|
import Foreign.Storable (peek)
|
||||||
import Test.Tasty
|
import Test.Tasty
|
||||||
import Test.Tasty.HUnit as HU (testCase, (@?=),
|
import Test.Tasty.HUnit as HU (testCase, (@?=),
|
||||||
|
@ -31,7 +28,7 @@ testCancelWhileHandling =
|
||||||
testCase "Client/Server - cancel after handler starts does nothing" $
|
testCase "Client/Server - cancel after handler starts does nothing" $
|
||||||
runSerialTest $ \grpc ->
|
runSerialTest $ \grpc ->
|
||||||
withClientServerUnaryCall grpc $
|
withClientServerUnaryCall grpc $
|
||||||
\(c@Client{..}, s@Server{..}, cc@ClientCall{..}, sc@ServerCall{..}) -> do
|
\(Client{..}, Server{..}, cc@ClientCall{..}, ServerCall{..}) -> do
|
||||||
withOpArrayAndCtxts serverEmptyRecvOps $ \(opArray, ctxts) -> do
|
withOpArrayAndCtxts serverEmptyRecvOps $ \(opArray, ctxts) -> do
|
||||||
tag <- newTag serverCQ
|
tag <- newTag serverCQ
|
||||||
startBatch serverCQ unServerCall opArray 3 tag
|
startBatch serverCQ unServerCall opArray 3 tag
|
||||||
|
@ -50,7 +47,7 @@ testCancelFromServer =
|
||||||
testCase "Client/Server - client receives server cancellation" $
|
testCase "Client/Server - client receives server cancellation" $
|
||||||
runSerialTest $ \grpc ->
|
runSerialTest $ \grpc ->
|
||||||
withClientServerUnaryCall grpc $
|
withClientServerUnaryCall grpc $
|
||||||
\(c@Client{..}, s@Server{..}, cc@ClientCall{..}, sc@ServerCall{..}) -> do
|
\(Client{..}, Server{..}, ClientCall{..}, sc@ServerCall{..}) -> do
|
||||||
serverCallCancel sc StatusPermissionDenied "TestStatus"
|
serverCallCancel sc StatusPermissionDenied "TestStatus"
|
||||||
clientRes <- runOps unClientCall clientCQ clientRecvOps
|
clientRes <- runOps unClientCall clientCQ clientRecvOps
|
||||||
case clientRes of
|
case clientRes of
|
||||||
|
@ -62,6 +59,7 @@ testCancelFromServer =
|
||||||
||
|
||
|
||||||
isPrefixOf "Received RST_STREAM" details
|
isPrefixOf "Received RST_STREAM" details
|
||||||
return $ Right ()
|
return $ Right ()
|
||||||
|
wrong -> error $ "Unexpected op results: " ++ show wrong
|
||||||
|
|
||||||
|
|
||||||
runSerialTest :: (GRPC -> IO (Either GRPCIOError ())) -> IO ()
|
runSerialTest :: (GRPC -> IO (Either GRPCIOError ())) -> IO ()
|
||||||
|
@ -83,22 +81,27 @@ withClientServerUnaryCall grpc f = do
|
||||||
-- because registered methods try to do recv ops immediately when
|
-- because registered methods try to do recv ops immediately when
|
||||||
-- created. If later we want to send payloads or metadata, we'll need
|
-- created. If later we want to send payloads or metadata, we'll need
|
||||||
-- to tweak this.
|
-- to tweak this.
|
||||||
clientRes <- runOps (unClientCall cc) (clientCQ c) clientEmptySendOps
|
_clientRes <- runOps (unClientCall cc) (clientCQ c) clientEmptySendOps
|
||||||
withServerCall s srm $ \sc ->
|
withServerCall s srm $ \sc ->
|
||||||
f (c, s, cc, sc)
|
f (c, s, cc, sc)
|
||||||
|
|
||||||
|
serverConf :: ServerConfig
|
||||||
serverConf = ServerConfig "localhost" 50051 [("/foo", Normal)] []
|
serverConf = ServerConfig "localhost" 50051 [("/foo", Normal)] []
|
||||||
|
|
||||||
|
clientConf :: ClientConfig
|
||||||
clientConf = ClientConfig "localhost" 50051 []
|
clientConf = ClientConfig "localhost" 50051 []
|
||||||
|
|
||||||
|
clientEmptySendOps :: [Op]
|
||||||
clientEmptySendOps = [OpSendInitialMetadata mempty,
|
clientEmptySendOps = [OpSendInitialMetadata mempty,
|
||||||
OpSendMessage "",
|
OpSendMessage "",
|
||||||
OpSendCloseFromClient]
|
OpSendCloseFromClient]
|
||||||
|
|
||||||
|
clientRecvOps :: [Op]
|
||||||
clientRecvOps = [OpRecvInitialMetadata,
|
clientRecvOps = [OpRecvInitialMetadata,
|
||||||
OpRecvMessage,
|
OpRecvMessage,
|
||||||
OpRecvStatusOnClient]
|
OpRecvStatusOnClient]
|
||||||
|
|
||||||
|
serverEmptyRecvOps :: [Op]
|
||||||
serverEmptyRecvOps = [OpSendInitialMetadata mempty,
|
serverEmptyRecvOps = [OpSendInitialMetadata mempty,
|
||||||
OpRecvMessage,
|
OpRecvMessage,
|
||||||
OpRecvCloseOnServer]
|
OpRecvCloseOnServer]
|
||||||
|
|
Loading…
Reference in a new issue