grpc-haskell-0.2.0.0: Upgrade to proto3-wire-1.2.0, proto3-suite-0.4.2.0 (#110)

* .gitignore

* release.nix: Minor cleanup

* Fix warning

* Expose max receive message length channel arg in `ServiceOptions`

* Fix warning

* Bump upstream dependencies and patch parameterized-0.5.0.0

* grpc-haskell 0.0.1.0 -> 0.0.2.0
This commit is contained in:
intractable 2020-11-16 11:43:28 -06:00 committed by GitHub
parent d8f6e0b476
commit 6382857e2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 109 additions and 50 deletions

3
.gitignore vendored
View file

@ -7,7 +7,8 @@ examples/echo/echo-cpp/echo-client
examples/echo/echo-cpp/echo-server examples/echo/echo-cpp/echo-server
benchmarks.html benchmarks.html
result result
*~ *~
cabal.project.local cabal.project.local
dist-newstyle/ dist-newstyle/
tests/py-tmp
tests/tmp

View file

@ -4,7 +4,6 @@ module Network.GRPC.Unsafe.Op where
{#import Network.GRPC.Unsafe.Slice#} {#import Network.GRPC.Unsafe.Slice#}
import Control.Exception
import Foreign.C.Types import Foreign.C.Types
import Foreign.Ptr import Foreign.Ptr
{#import Network.GRPC.Unsafe.ByteBuffer#} {#import Network.GRPC.Unsafe.ByteBuffer#}

View file

@ -5,7 +5,7 @@
}: }:
mkDerivation { mkDerivation {
pname = "grpc-haskell"; pname = "grpc-haskell";
version = "0.0.0.0"; version = "0.0.2.0";
src = ./.; src = ./.;
isLibrary = true; isLibrary = true;
isExecutable = true; isExecutable = true;

View file

@ -1,5 +1,5 @@
name: grpc-haskell name: grpc-haskell
version: 0.0.1.0 version: 0.0.2.0
synopsis: Haskell implementation of gRPC layered on shared C library. synopsis: Haskell implementation of gRPC layered on shared C library.
homepage: https://github.com/awakenetworks/gRPC-haskell homepage: https://github.com/awakenetworks/gRPC-haskell
license: Apache-2.0 license: Apache-2.0
@ -29,10 +29,9 @@ library
build-depends: build-depends:
base >=4.8 && <5.0 base >=4.8 && <5.0
, bytestring ==0.10.* , bytestring ==0.10.*
, proto3-suite >=0.4.0.0 , proto3-suite >=0.4.2.0
, proto3-wire , proto3-wire >=1.2.0
, grpc-haskell-core , grpc-haskell-core
, async >=2.1 && <2.3 , async >=2.1 && <2.3
, managed >= 1.0.5 , managed >= 1.0.5

44
nix/parameterized.patch Normal file
View file

@ -0,0 +1,44 @@
diff --git a/test/Parameterized/Control/Monad/Trans/Reader/ReaderSpec.hs b/test/Parameterized/Control/Monad/Trans/Reader/ReaderSpec.hs
index a39d181..1999e57 100644
--- a/test/Parameterized/Control/Monad/Trans/Reader/ReaderSpec.hs
+++ b/test/Parameterized/Control/Monad/Trans/Reader/ReaderSpec.hs
@@ -91,7 +91,7 @@ whichIntBoolStringReader = do
manyIntMaybeReader :: ReaderT (Many '[Int]) Maybe String
manyIntMaybeReader = do
a <- ask
- let r = fetch @Int a
+ let r = grab @Int a
case r of
0 -> empty
r' -> pure $ show r'
@@ -99,7 +99,7 @@ manyIntMaybeReader = do
manyBoolMaybeReader :: ReaderT (Many '[Bool]) Maybe String
manyBoolMaybeReader = do
a <- ask
- let r = fetch @Bool a
+ let r = grab @Bool a
case r of
False -> empty
r' -> pure $ show r'
diff --git a/test/Parameterized/Control/Monad/Trans/State/Strict/StateSpec.hs b/test/Parameterized/Control/Monad/Trans/State/Strict/StateSpec.hs
index 7dfd46c..4777c13 100644
--- a/test/Parameterized/Control/Monad/Trans/State/Strict/StateSpec.hs
+++ b/test/Parameterized/Control/Monad/Trans/State/Strict/StateSpec.hs
@@ -26,7 +26,7 @@ main = hspec spec
manyIntMaybeState :: StateT (Many '[Int]) Maybe String
manyIntMaybeState= do
s <- get
- let r = fetch @Int s
+ let r = grab @Int s
case r of
0 -> empty
r' -> do
@@ -36,7 +36,7 @@ manyIntMaybeState= do
manyBoolMaybeState :: StateT (Many '[Bool]) Maybe String
manyBoolMaybeState = do
s <- get
- let r = fetch @Bool s
+ let r = grab @Bool s
case r of
False -> empty
r' -> do

View file

@ -5,17 +5,16 @@
, insert-ordered-containers, lens, mtl, neat-interpolation , insert-ordered-containers, lens, mtl, neat-interpolation
, optparse-applicative, optparse-generic, parsec, parsers, pretty , optparse-applicative, optparse-generic, parsec, parsers, pretty
, pretty-show, proto3-wire, QuickCheck, quickcheck-instances , pretty-show, proto3-wire, QuickCheck, quickcheck-instances
, range-set-list, safe, semigroups, stdenv, swagger2 , range-set-list, safe, stdenv, swagger2, system-filepath, tasty
, system-filepath, tasty, tasty-hunit, tasty-quickcheck, text , tasty-hunit, tasty-quickcheck, text, transformers, turtle, vector
, transformers, turtle, vector
}: }:
mkDerivation { mkDerivation {
pname = "proto3-suite"; pname = "proto3-suite";
version = "0.4.0.0"; version = "0.4.2.0";
src = fetchgit { src = fetchgit {
url = "https://github.com/awakesecurity/proto3-suite"; url = "https://github.com/awakesecurity/proto3-suite.git";
sha256 = "0g7j7axx9rkrzw32ky9xl08zj34rx4mqafd89lrpnsi8lcq2z06j"; sha256 = "0mpy35r6qd1v5sixhy2lqcn5x81rfj4dc079g1kpa4fb1f23dbha";
rev = "3f6dd6f612cf2eba3c05798926ff924b0d5ab4fa"; rev = "0af901f9ef3b9719e08eae4fab8fd700d6c8047a";
fetchSubmodules = true; fetchSubmodules = true;
}; };
isLibrary = true; isLibrary = true;
@ -26,8 +25,8 @@ mkDerivation {
bytestring cereal containers contravariant deepseq filepath foldl bytestring cereal containers contravariant deepseq filepath foldl
hashable haskell-src insert-ordered-containers lens mtl hashable haskell-src insert-ordered-containers lens mtl
neat-interpolation parsec parsers pretty pretty-show proto3-wire neat-interpolation parsec parsers pretty pretty-show proto3-wire
QuickCheck quickcheck-instances safe semigroups swagger2 QuickCheck quickcheck-instances safe swagger2 system-filepath text
system-filepath text transformers turtle vector transformers turtle vector
]; ];
executableHaskellDepends = [ executableHaskellDepends = [
base containers mtl optparse-applicative optparse-generic base containers mtl optparse-applicative optparse-generic
@ -36,8 +35,8 @@ mkDerivation {
testHaskellDepends = [ testHaskellDepends = [
aeson attoparsec base base64-bytestring bytestring cereal aeson attoparsec base base64-bytestring bytestring cereal
containers deepseq doctest generic-arbitrary mtl pretty-show containers deepseq doctest generic-arbitrary mtl pretty-show
proto3-wire QuickCheck semigroups swagger2 tasty tasty-hunit proto3-wire QuickCheck swagger2 tasty tasty-hunit tasty-quickcheck
tasty-quickcheck text transformers turtle vector text transformers turtle vector
]; ];
description = "A low level library for writing out data in the Protocol Buffers wire format"; description = "A low level library for writing out data in the Protocol Buffers wire format";
license = stdenv.lib.licenses.asl20; license = stdenv.lib.licenses.asl20;

View file

@ -1,23 +1,25 @@
{ mkDerivation, base, bytestring, cereal, containers, deepseq { mkDerivation, base, bytestring, cereal, containers, deepseq
, doctest, fetchgit, hashable, QuickCheck, safe, stdenv, tasty , doctest, fetchgit, ghc-prim, hashable, parameterized, primitive
, tasty-hunit, tasty-quickcheck, text, unordered-containers , QuickCheck, safe, stdenv, tasty, tasty-hunit, tasty-quickcheck
, text, transformers, unordered-containers, vector
}: }:
mkDerivation { mkDerivation {
pname = "proto3-wire"; pname = "proto3-wire";
version = "1.1.0"; version = "1.2.0";
src = fetchgit { src = fetchgit {
url = "https://github.com/awakesecurity/proto3-wire.git"; url = "https://github.com/awakesecurity/proto3-wire.git";
sha256 = "16l1rnnygwk1b2sb3l6klhr6ad0wvry204icxnc81c6rbzbk6rqc"; sha256 = "062b05ab8icwjxaqrh3wmg8s26m620pigqj3dj6rdx9qas1cq6mi";
rev = "4f355bbac895d577d8a28f567ab4380f042ccc24"; rev = "d92ec32ef0f15842b07fb226d8f2d15f36c5fb20";
fetchSubmodules = true; fetchSubmodules = true;
}; };
libraryHaskellDepends = [ libraryHaskellDepends = [
base bytestring cereal containers deepseq hashable QuickCheck safe base bytestring cereal containers deepseq ghc-prim hashable
text unordered-containers parameterized primitive QuickCheck safe text transformers
unordered-containers vector
]; ];
testHaskellDepends = [ testHaskellDepends = [
base bytestring cereal doctest QuickCheck tasty tasty-hunit base bytestring cereal doctest QuickCheck tasty tasty-hunit
tasty-quickcheck text tasty-quickcheck text transformers vector
]; ];
description = "A low-level implementation of the Protocol Buffers (version 3) wire format"; description = "A low-level implementation of the Protocol Buffers (version 3) wire format";
license = stdenv.lib.licenses.asl20; license = stdenv.lib.licenses.asl20;

View file

@ -63,13 +63,12 @@ let
config = { config = {
allowUnfree = true; allowUnfree = true;
# For parameterized-0.5.0.0, which we patch for compatbility with
# proto3-wire-1.2.0 (which also uses the same patch)
allowBroken = true;
}; };
overlay = pkgsNew: pkgsOld: { overlay = pkgsNew: pkgsOld: {
protobuf3_2NoCheck =
pkgsNew.stdenv.lib.overrideDerivation
pkgsNew.pythonPackages.protobuf
(oldAttrs : {doCheck = false; doInstallCheck = false;});
cython = pkgsNew.pythonPackages.buildPythonPackage rec { cython = pkgsNew.pythonPackages.buildPythonPackage rec {
name = "Cython-${version}"; name = "Cython-${version}";
@ -177,26 +176,6 @@ let
]; ];
}; };
usesGRPC = haskellPackage:
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
'';
}
);
haskellPackages = pkgsOld.haskellPackages.override { haskellPackages = pkgsOld.haskellPackages.override {
overrides = haskellPackagesNew: haskellPackagesOld: rec { overrides = haskellPackagesNew: haskellPackagesOld: rec {
@ -283,9 +262,16 @@ let
}) })
); );
parameterized = pkgsNew.haskell.lib.appendPatch haskellPackagesOld.parameterized ./nix/parameterized.patch;
}; };
}; };
protobuf3_2NoCheck =
pkgsNew.stdenv.lib.overrideDerivation
pkgsNew.pythonPackages.protobuf
(oldAttrs : {doCheck = false; doInstallCheck = false;});
test-grpc-haskell = test-grpc-haskell =
pkgsNew.mkShell { pkgsNew.mkShell {
nativeBuildInputs = [ nativeBuildInputs = [
@ -296,6 +282,26 @@ let
) )
]; ];
}; };
usesGRPC = haskellPackage:
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
'';
}
);
}; };
overlays = [ overlay ]; overlays = [ overlay ];

View file

@ -42,6 +42,7 @@ import Network.GRPC.HighLevel.Server
import Network.GRPC.HighLevel.Client import Network.GRPC.HighLevel.Client
import Network.GRPC.LowLevel import Network.GRPC.LowLevel
import Network.GRPC.LowLevel.Call import Network.GRPC.LowLevel.Call
import Numeric.Natural
import System.IO (hPutStrLn, stderr) import System.IO (hPutStrLn, stderr)
-- | Used at the kind level as a parameter to service definitions -- | Used at the kind level as a parameter to service definitions
@ -78,6 +79,8 @@ data ServiceOptions = ServiceOptions
-- ^ Security configuration. -- ^ Security configuration.
, logger :: String -> IO () , logger :: String -> IO ()
-- ^ Logging function to use to log errors in handling calls. -- ^ Logging function to use to log errors in handling calls.
, serverMaxReceiveMessageLength :: Maybe Natural
-- ^ Maximum length (in bytes) that the service may receive in a single message
} }
defaultServiceOptions :: ServiceOptions defaultServiceOptions :: ServiceOptions
@ -91,6 +94,7 @@ defaultServiceOptions = ServiceOptions
, Network.GRPC.HighLevel.Generated.initialMetadata = mempty , Network.GRPC.HighLevel.Generated.initialMetadata = mempty
, Network.GRPC.HighLevel.Generated.sslConfig = Nothing , Network.GRPC.HighLevel.Generated.sslConfig = Nothing
, Network.GRPC.HighLevel.Generated.logger = hPutStrLn stderr , Network.GRPC.HighLevel.Generated.logger = hPutStrLn stderr
, Network.GRPC.HighLevel.Generated.serverMaxReceiveMessageLength = Nothing
} }
withGRPCClient :: ClientConfig -> (Client -> IO a) -> IO a withGRPCClient :: ClientConfig -> (Client -> IO a) -> IO a

View file

@ -13,6 +13,7 @@ import Control.Monad
import Data.ByteString (ByteString) import Data.ByteString (ByteString)
import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Lazy as BL
import Network.GRPC.LowLevel import Network.GRPC.LowLevel
import Numeric.Natural
import Proto3.Suite.Class import Proto3.Suite.Class
import System.IO import System.IO
@ -225,6 +226,7 @@ data ServerOptions = ServerOptions
-- ^ Security configuration. -- ^ Security configuration.
, optLogger :: String -> IO () , optLogger :: String -> IO ()
-- ^ Logging function to use to log errors in handling calls. -- ^ Logging function to use to log errors in handling calls.
, optMaxReceiveMessageLength :: Maybe Natural
} }
defaultOptions :: ServerOptions defaultOptions :: ServerOptions
@ -241,6 +243,7 @@ defaultOptions = ServerOptions
, optInitialMetadata = mempty , optInitialMetadata = mempty
, optSSLConfig = Nothing , optSSLConfig = Nothing
, optLogger = hPutStrLn stderr , optLogger = hPutStrLn stderr
, optMaxReceiveMessageLength = Nothing
} }
serverLoop :: ServerOptions -> IO () serverLoop :: ServerOptions -> IO ()

View file

@ -122,5 +122,7 @@ serverLoop ServerOptions{..} =
[ UserAgentPrefix optUserAgentPrefix [ UserAgentPrefix optUserAgentPrefix
, UserAgentSuffix optUserAgentSuffix , UserAgentSuffix optUserAgentSuffix
] ]
++
foldMap (pure . MaxReceiveMessageLength) optMaxReceiveMessageLength
, sslConfig = optSSLConfig , sslConfig = optSSLConfig
} }