mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-11-14 07:09:41 +01:00
Minor cleanup (#130)
* Remove unnecessary self-dependency * Regenerate core/default.nix and build -core via callCabal2nix * grpc-haskell-core: -Wall -Werror and fix warnings * grpc-haskell: -Wall -Werror and fix warnings * Update documentation * Remove LD_LIBRARY_PATH sets from usesGRPC ...as they no longer seem to be needed. * Remove dead code * Remove core/default.nix ...as suggested by @evanrelf.
This commit is contained in:
parent
28e9e68f3b
commit
b9ed537f64
15 changed files with 27 additions and 69 deletions
|
@ -7,7 +7,7 @@ have extended and released under the same [`LICENSE`](./LICENSE)
|
|||
Installation
|
||||
------------
|
||||
|
||||
**The current version of this library requires gRPC version 1.2.0. Newer versions may work but have not been tested.**
|
||||
**The current version of this library requires gRPC version 1.34.1. Newer versions may work but have not been tested.**
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
{ mkDerivation, async, base, bytestring, c2hs, clock, containers
|
||||
, grpc, managed, pipes, proto3-suite, proto3-wire, QuickCheck, safe
|
||||
, sorted-list, stdenv, stm, tasty, tasty-hunit, tasty-quickcheck
|
||||
, text, time, transformers, turtle, unix, vector
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "grpc-haskell-core";
|
||||
version = "0.0.0.0";
|
||||
src = ./.;
|
||||
libraryHaskellDepends = [
|
||||
async base bytestring clock containers managed pipes proto3-suite
|
||||
proto3-wire safe sorted-list stm tasty tasty-hunit tasty-quickcheck
|
||||
transformers vector
|
||||
];
|
||||
librarySystemDepends = [ grpc ];
|
||||
libraryToolDepends = [ c2hs ];
|
||||
testHaskellDepends = [
|
||||
async base bytestring clock containers managed pipes proto3-suite
|
||||
QuickCheck safe tasty tasty-hunit tasty-quickcheck text time
|
||||
transformers turtle unix
|
||||
];
|
||||
homepage = "https://github.com/awakenetworks/gRPC-haskell";
|
||||
description = "Haskell implementation of gRPC layered on shared C library";
|
||||
license = stdenv.lib.licenses.asl20;
|
||||
}
|
|
@ -68,7 +68,7 @@ library
|
|||
, grpc/slice.h
|
||||
build-tools: c2hs
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall -fwarn-incomplete-patterns -fno-warn-unused-do-bind
|
||||
ghc-options: -Wall -Werror -fwarn-incomplete-patterns -fno-warn-unused-do-bind
|
||||
include-dirs: include
|
||||
hs-source-dirs: src
|
||||
default-extensions: CPP
|
||||
|
@ -103,7 +103,7 @@ test-suite tests
|
|||
LowLevelTests.Op,
|
||||
UnsafeTests
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall -fwarn-incomplete-patterns -fno-warn-unused-do-bind -g -threaded -rtsopts
|
||||
ghc-options: -Wall -Werror -fwarn-incomplete-patterns -fno-warn-unused-do-bind -g -threaded -rtsopts
|
||||
hs-source-dirs: tests
|
||||
main-is: Properties.hs
|
||||
type: exitcode-stdio-1.0
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
{-# LANGUAGE KindSignatures #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
{-# LANGUAGE NamedFieldPuns #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE StandaloneDeriving #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
|
@ -212,8 +212,8 @@ destroyClientCall cc = do
|
|||
C.grpcCallUnref (unsafeCC cc)
|
||||
|
||||
destroyServerCall :: ServerCall a -> IO ()
|
||||
destroyServerCall sc@ServerCall{ unsafeSC = c, .. } = do
|
||||
destroyServerCall sc@ServerCall{ unsafeSC } = do
|
||||
grpcDebug "destroyServerCall(R): entered."
|
||||
debugServerCall sc
|
||||
grpcDebug $ "Destroying server-side call object: " ++ show c
|
||||
C.grpcCallUnref c
|
||||
grpcDebug $ "Destroying server-side call object: " ++ show unsafeSC
|
||||
C.grpcCallUnref unsafeSC
|
||||
|
|
|
@ -71,7 +71,7 @@ createCompletionQueue _ = do
|
|||
-- Throws 'CallError' if 'grpcCallStartBatch' returns a non-OK code.
|
||||
startBatch :: CompletionQueue -> C.Call -> C.OpArray -> Int -> C.Tag
|
||||
-> IO (Either GRPCIOError ())
|
||||
startBatch cq@CompletionQueue{..} call opArray opArraySize tag =
|
||||
startBatch cq call opArray opArraySize tag =
|
||||
withPermission Push cq $ fmap throwIfCallError $ do
|
||||
grpcDebug $ "startBatch: calling grpc_call_start_batch with pointers: "
|
||||
++ show call ++ " " ++ show opArray
|
||||
|
|
|
@ -104,7 +104,7 @@ withPermission op cq act = bracket acquire release $ \gotResource ->
|
|||
-- 'serverRequestCall', this will block forever unless a timeout is given.
|
||||
pluck :: CompletionQueue -> C.Tag -> Maybe TimeoutSeconds
|
||||
-> IO (Either GRPCIOError ())
|
||||
pluck cq@CompletionQueue{..} tag mwait = do
|
||||
pluck cq tag mwait = do
|
||||
grpcDebug $ "pluck: called with tag=" ++ show tag ++ ",mwait=" ++ show mwait
|
||||
withPermission Pluck cq $ pluck' cq tag mwait
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import Control.Exception (bracket)
|
|||
import Control.Monad
|
||||
|
||||
import Data.ByteString (ByteString, useAsCString)
|
||||
import Data.Semigroup (Semigroup)
|
||||
|
||||
import Foreign.C.String (CString, peekCString)
|
||||
import Foreign.Marshal.Alloc (free)
|
||||
|
|
|
@ -12,7 +12,6 @@ import Data.Function (on)
|
|||
import Data.ByteString (ByteString, useAsCString,
|
||||
useAsCStringLen)
|
||||
import Data.List (sortBy, groupBy)
|
||||
import Data.Semigroup (Semigroup((<>)))
|
||||
import qualified Data.SortedList as SL
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Ord (comparing)
|
||||
|
|
|
@ -22,7 +22,6 @@ import Data.List (find)
|
|||
import qualified Data.Map.Strict as M
|
||||
import qualified Data.Set as S
|
||||
import GHC.Exts (fromList, toList)
|
||||
import Network.GRPC.Unsafe.ChannelArgs (Arg(..))
|
||||
import Network.GRPC.LowLevel
|
||||
import qualified Network.GRPC.LowLevel.Call.Unregistered as U
|
||||
import qualified Network.GRPC.LowLevel.Client.Unregistered as U
|
||||
|
@ -183,7 +182,7 @@ testSSL =
|
|||
Nothing)
|
||||
}
|
||||
server = TestServer serverConf' $ \s -> do
|
||||
r <- U.serverHandleNormalCall s mempty $ \U.ServerCall{..} body -> do
|
||||
r <- U.serverHandleNormalCall s mempty $ \U.ServerCall{} body -> do
|
||||
body @?= "hi"
|
||||
return ("reply test", mempty, StatusOk, "")
|
||||
r @?= Right ()
|
||||
|
@ -282,7 +281,7 @@ testAuthMetadataTransfer =
|
|||
serverProcessor)
|
||||
}
|
||||
server = TestServer serverConf' $ \s -> do
|
||||
r <- U.serverHandleNormalCall s mempty $ \U.ServerCall{..} body -> do
|
||||
r <- U.serverHandleNormalCall s mempty $ \U.ServerCall{} body -> do
|
||||
body @?= "hi"
|
||||
return ("reply test", mempty, StatusOk, "")
|
||||
r @?= Right ()
|
||||
|
|
|
@ -27,7 +27,7 @@ testCancelFromServer =
|
|||
testCase "Client/Server - client receives server cancellation" $
|
||||
runSerialTest $ \grpc ->
|
||||
withClientServerUnaryCall grpc $
|
||||
\(Client {..}, Server {..}, ClientCall {..}, sc@ServerCall {..}) -> do
|
||||
\(Client {..}, Server {}, ClientCall {..}, sc@ServerCall {}) -> do
|
||||
serverCallCancel sc StatusPermissionDenied "TestStatus"
|
||||
clientRes <- runOps unsafeCC clientCQ clientRecvOps
|
||||
case clientRes of
|
||||
|
|
|
@ -20,7 +20,6 @@ import Network.GRPC.Unsafe.Slice
|
|||
import Network.GRPC.Unsafe.Time
|
||||
import System.Clock
|
||||
import Test.QuickCheck.Gen
|
||||
import qualified Test.QuickCheck.Property as QC
|
||||
import Test.Tasty
|
||||
import Test.Tasty.HUnit as HU (testCase, (@?=))
|
||||
import Test.Tasty.QuickCheck as QC
|
||||
|
|
|
@ -12,7 +12,6 @@ import Data.ByteString (ByteString)
|
|||
import Data.Maybe (fromMaybe)
|
||||
import qualified Data.Text.Lazy as TL
|
||||
import Echo
|
||||
import GHC.Generics (Generic)
|
||||
import Network.GRPC.HighLevel.Client
|
||||
import Network.GRPC.LowLevel
|
||||
import Options.Generic
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
import Data.ByteString (ByteString)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import GHC.Generics (Generic)
|
||||
import Network.GRPC.HighLevel.Generated (GRPCMethodType (..),
|
||||
Host (..), Port (..),
|
||||
ServerRequest (..),
|
||||
|
|
|
@ -42,7 +42,7 @@ library
|
|||
Network.GRPC.HighLevel.Server.Unregistered
|
||||
Network.GRPC.HighLevel.Client
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall -fwarn-incomplete-patterns -fno-warn-unused-do-bind
|
||||
ghc-options: -Wall -Werror -fwarn-incomplete-patterns -fno-warn-unused-do-bind
|
||||
hs-source-dirs: src
|
||||
default-extensions: CPP
|
||||
CC-Options: -std=c99
|
||||
|
@ -66,7 +66,7 @@ executable hellos-server
|
|||
else
|
||||
buildable: False
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall -g -threaded -rtsopts -with-rtsopts=-N -O2
|
||||
ghc-options: -Wall -Werror -g -threaded -rtsopts -with-rtsopts=-N -O2
|
||||
hs-source-dirs: examples/hellos/hellos-server
|
||||
main-is: Main.hs
|
||||
|
||||
|
@ -86,7 +86,7 @@ executable hellos-client
|
|||
else
|
||||
buildable: False
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall -g -threaded -rtsopts -with-rtsopts=-N -O2
|
||||
ghc-options: -Wall -Werror -g -threaded -rtsopts -with-rtsopts=-N -O2
|
||||
hs-source-dirs: examples/hellos/hellos-client
|
||||
main-is: Main.hs
|
||||
|
||||
|
@ -110,7 +110,7 @@ executable echo-server
|
|||
else
|
||||
buildable: False
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall -g -threaded -rtsopts -with-rtsopts=-N -O2
|
||||
ghc-options: -Wall -Werror -g -threaded -rtsopts -with-rtsopts=-N -O2
|
||||
hs-source-dirs: examples/echo/echo-hs
|
||||
main-is: EchoServer.hs
|
||||
|
||||
|
@ -135,7 +135,7 @@ executable arithmetic-server
|
|||
else
|
||||
buildable: False
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall -g -threaded -rtsopts -with-rtsopts=-N -O2
|
||||
ghc-options: -Wall -Werror -g -threaded -rtsopts -with-rtsopts=-N -O2
|
||||
hs-source-dirs: examples/tutorial/
|
||||
main-is: ArithmeticServer.hs
|
||||
|
||||
|
@ -159,7 +159,7 @@ executable arithmetic-client
|
|||
else
|
||||
buildable: False
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall -g -threaded -rtsopts -with-rtsopts=-N -O2
|
||||
ghc-options: -Wall -Werror -g -threaded -rtsopts -with-rtsopts=-N -O2
|
||||
hs-source-dirs: examples/tutorial/
|
||||
main-is: ArithmeticClient.hs
|
||||
|
||||
|
@ -184,14 +184,13 @@ executable echo-client
|
|||
else
|
||||
buildable: False
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall -g -threaded -rtsopts -with-rtsopts=-N -O2
|
||||
ghc-options: -Wall -Werror -g -threaded -rtsopts -with-rtsopts=-N -O2
|
||||
hs-source-dirs: examples/echo/echo-hs
|
||||
main-is: EchoClient.hs
|
||||
|
||||
test-suite tests
|
||||
build-depends:
|
||||
base >=4.8 && <5.0
|
||||
, grpc-haskell
|
||||
, bytestring ==0.10.*
|
||||
, unix
|
||||
, time
|
||||
|
@ -212,7 +211,7 @@ test-suite tests
|
|||
other-modules:
|
||||
GeneratedTests
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall -fwarn-incomplete-patterns -fno-warn-unused-do-bind -g -threaded -rtsopts
|
||||
ghc-options: -Wall -Werror -fwarn-incomplete-patterns -fno-warn-unused-do-bind -g -threaded -rtsopts
|
||||
hs-source-dirs: tests
|
||||
main-is: Properties.hs
|
||||
type: exitcode-stdio-1.0
|
||||
|
@ -233,7 +232,7 @@ benchmark bench
|
|||
, random >=1.0.0
|
||||
hs-source-dirs: bench
|
||||
main-is: Bench.hs
|
||||
ghc-options: -Wall -O2 -threaded -rtsopts -with-rtsopts=-N
|
||||
ghc-options: -Wall -Werror -O2 -threaded -rtsopts -with-rtsopts=-N
|
||||
if flag(debug)
|
||||
CPP-Options: -DDEBUG
|
||||
CC-Options: -DGRPC_HASKELL_DEBUG
|
||||
|
|
22
release.nix
22
release.nix
|
@ -94,9 +94,11 @@ let
|
|||
|
||||
grpc-haskell-core =
|
||||
pkgsNew.haskell.lib.buildFromSdist (pkgsNew.usesGRPC
|
||||
(pkgsNew.haskell.lib.overrideCabal
|
||||
(haskellPackagesNew.callPackage ./core { })
|
||||
(_: { buildDepends = [ haskellPackagesNew.c2hs ]; })));
|
||||
(haskellPackagesNew.callCabal2nix "grpc-haskell-core" ./core {
|
||||
gpr = pkgsNew.grpc;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
grpc-haskell-no-tests =
|
||||
pkgsNew.haskell.lib.buildFromSdist (pkgsNew.usesGRPC
|
||||
|
@ -120,7 +122,6 @@ let
|
|||
]);
|
||||
|
||||
python = pkgsNew.python.withPackages (pkgs: [
|
||||
# pkgs.protobuf3_0
|
||||
pkgs.grpcio-tools
|
||||
]);
|
||||
|
||||
|
@ -173,11 +174,6 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
protobuf3_2NoCheck =
|
||||
pkgsNew.stdenv.lib.overrideDerivation
|
||||
pkgsNew.pythonPackages.protobuf
|
||||
(oldAttrs : {doCheck = false; doInstallCheck = false;});
|
||||
|
||||
test-grpc-haskell =
|
||||
pkgsNew.mkShell {
|
||||
nativeBuildInputs = [
|
||||
|
@ -190,21 +186,15 @@ let
|
|||
};
|
||||
|
||||
usesGRPC = haskellPackage:
|
||||
# TODO: Try using pkgsNew.fixDarwinDylibNames (see PR#129).
|
||||
pkgsNew.haskell.lib.overrideCabal haskellPackage (oldAttributes: {
|
||||
preBuild = (oldAttributes.preBuild or "") +
|
||||
pkgsNew.lib.optionalString pkgsNew.stdenv.isDarwin ''
|
||||
export DYLD_LIBRARY_PATH=${pkgsNew.grpc}/lib''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH
|
||||
'' +
|
||||
pkgsNew.lib.optionalString pkgsNew.stdenv.isLinux ''
|
||||
export LD_LIBRARY_PATH=${pkgsNew.grpc}/lib''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH
|
||||
'';
|
||||
|
||||
shellHook = (oldAttributes.shellHook or "") +
|
||||
pkgsNew.lib.optionalString pkgsNew.stdenv.isDarwin ''
|
||||
export DYLD_LIBRARY_PATH=${pkgsNew.grpc}/lib''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH
|
||||
'' +
|
||||
pkgsNew.lib.optionalString pkgsNew.stdenv.isLinux ''
|
||||
export LD_LIBRARY_PATH=${pkgsNew.grpc}/lib''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH
|
||||
'';
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue