mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-11-26 21:19:43 +01:00
Move to newer proto3-suite. (#81)
This commit is contained in:
parent
75cf21839b
commit
c83eacd1f3
11 changed files with 144 additions and 79 deletions
13
default.nix
13
default.nix
|
@ -1,8 +1,7 @@
|
||||||
{ mkDerivation, async, base, bytestring, c2hs, clock, containers
|
{ mkDerivation, async, base, bytestring, clock, containers
|
||||||
, criterion, grpc-haskell-core, managed, pipes, proto3-suite
|
, criterion, grpc-haskell-core, managed, pipes, proto3-suite
|
||||||
, proto3-wire, QuickCheck, random, safe, sorted-list, stdenv, stm
|
, proto3-wire, QuickCheck, random, safe, stdenv, tasty, tasty-hunit
|
||||||
, tasty, tasty-hunit, tasty-quickcheck, text, time, transformers
|
, tasty-quickcheck, text, time, transformers, turtle, unix
|
||||||
, turtle, unix, vector
|
|
||||||
}:
|
}:
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
pname = "grpc-haskell";
|
pname = "grpc-haskell";
|
||||||
|
@ -11,11 +10,9 @@ mkDerivation {
|
||||||
isLibrary = true;
|
isLibrary = true;
|
||||||
isExecutable = true;
|
isExecutable = true;
|
||||||
libraryHaskellDepends = [
|
libraryHaskellDepends = [
|
||||||
async base bytestring clock containers grpc-haskell-core managed
|
async base bytestring grpc-haskell-core managed proto3-suite
|
||||||
pipes proto3-suite proto3-wire safe sorted-list stm tasty
|
proto3-wire
|
||||||
tasty-hunit tasty-quickcheck transformers vector
|
|
||||||
];
|
];
|
||||||
libraryToolDepends = [ c2hs ];
|
|
||||||
testHaskellDepends = [
|
testHaskellDepends = [
|
||||||
async base bytestring clock containers managed pipes proto3-suite
|
async base bytestring clock containers managed pipes proto3-suite
|
||||||
QuickCheck safe tasty tasty-hunit tasty-quickcheck text time
|
QuickCheck safe tasty tasty-hunit tasty-quickcheck text time
|
||||||
|
|
4
examples/echo/echo-hs/Echo.hs
generated
4
examples/echo/echo-hs/Echo.hs
generated
|
@ -87,7 +87,7 @@ instance HsProtobuf.Message EchoRequest where
|
||||||
(HsProtobuf.Prim HsProtobuf.String)
|
(HsProtobuf.Prim HsProtobuf.String)
|
||||||
(HsProtobuf.Single "message")
|
(HsProtobuf.Single "message")
|
||||||
[]
|
[]
|
||||||
Hs.Nothing)]
|
"")]
|
||||||
|
|
||||||
instance HsJSONPB.ToJSONPB EchoRequest where
|
instance HsJSONPB.ToJSONPB EchoRequest where
|
||||||
toJSONPB (EchoRequest f1) = (HsJSONPB.object ["message" .= f1])
|
toJSONPB (EchoRequest f1) = (HsJSONPB.object ["message" .= f1])
|
||||||
|
@ -142,7 +142,7 @@ instance HsProtobuf.Message EchoResponse where
|
||||||
(HsProtobuf.Prim HsProtobuf.String)
|
(HsProtobuf.Prim HsProtobuf.String)
|
||||||
(HsProtobuf.Single "message")
|
(HsProtobuf.Single "message")
|
||||||
[]
|
[]
|
||||||
Hs.Nothing)]
|
"")]
|
||||||
|
|
||||||
instance HsJSONPB.ToJSONPB EchoResponse where
|
instance HsJSONPB.ToJSONPB EchoResponse where
|
||||||
toJSONPB (EchoResponse f1) = (HsJSONPB.object ["message" .= f1])
|
toJSONPB (EchoResponse f1) = (HsJSONPB.object ["message" .= f1])
|
||||||
|
|
|
@ -14,7 +14,6 @@ import qualified Data.Text.Lazy as TL
|
||||||
import Echo
|
import Echo
|
||||||
import GHC.Generics (Generic)
|
import GHC.Generics (Generic)
|
||||||
import Network.GRPC.HighLevel.Client
|
import Network.GRPC.HighLevel.Client
|
||||||
import Network.GRPC.HighLevel.Generated
|
|
||||||
import Network.GRPC.LowLevel
|
import Network.GRPC.LowLevel
|
||||||
import Options.Generic
|
import Options.Generic
|
||||||
import Prelude hiding (FilePath)
|
import Prelude hiding (FilePath)
|
||||||
|
|
6
examples/tutorial/Arithmetic.hs
generated
6
examples/tutorial/Arithmetic.hs
generated
|
@ -111,12 +111,12 @@ instance HsProtobuf.Message TwoInts where
|
||||||
(HsProtobuf.Prim HsProtobuf.Int32)
|
(HsProtobuf.Prim HsProtobuf.Int32)
|
||||||
(HsProtobuf.Single "x")
|
(HsProtobuf.Single "x")
|
||||||
[]
|
[]
|
||||||
Hs.Nothing),
|
""),
|
||||||
(HsProtobuf.DotProtoField (HsProtobuf.FieldNumber 2)
|
(HsProtobuf.DotProtoField (HsProtobuf.FieldNumber 2)
|
||||||
(HsProtobuf.Prim HsProtobuf.Int32)
|
(HsProtobuf.Prim HsProtobuf.Int32)
|
||||||
(HsProtobuf.Single "y")
|
(HsProtobuf.Single "y")
|
||||||
[]
|
[]
|
||||||
Hs.Nothing)]
|
"")]
|
||||||
|
|
||||||
instance HsJSONPB.ToJSONPB TwoInts where
|
instance HsJSONPB.ToJSONPB TwoInts where
|
||||||
toJSONPB (TwoInts f1 f2) = (HsJSONPB.object ["x" .= f1, "y" .= f2])
|
toJSONPB (TwoInts f1 f2) = (HsJSONPB.object ["x" .= f1, "y" .= f2])
|
||||||
|
@ -174,7 +174,7 @@ instance HsProtobuf.Message OneInt where
|
||||||
(HsProtobuf.Prim HsProtobuf.Int32)
|
(HsProtobuf.Prim HsProtobuf.Int32)
|
||||||
(HsProtobuf.Single "result")
|
(HsProtobuf.Single "result")
|
||||||
[]
|
[]
|
||||||
Hs.Nothing)]
|
"")]
|
||||||
|
|
||||||
instance HsJSONPB.ToJSONPB OneInt where
|
instance HsJSONPB.ToJSONPB OneInt where
|
||||||
toJSONPB (OneInt f1) = (HsJSONPB.object ["result" .= f1])
|
toJSONPB (OneInt f1) = (HsJSONPB.object ["result" .= f1])
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name: grpc-haskell
|
name: grpc-haskell
|
||||||
version: 0.0.0.0
|
version: 0.0.1.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
|
||||||
|
@ -25,7 +25,7 @@ library
|
||||||
build-depends:
|
build-depends:
|
||||||
base >=4.8 && <5.0
|
base >=4.8 && <5.0
|
||||||
, bytestring ==0.10.*
|
, bytestring ==0.10.*
|
||||||
, proto3-suite
|
, proto3-suite >=0.4.0.0
|
||||||
, proto3-wire
|
, proto3-wire
|
||||||
, grpc-haskell-core
|
, grpc-haskell-core
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ test-suite tests
|
||||||
, clock >=0.6.0 && <0.8.0
|
, clock >=0.6.0 && <0.8.0
|
||||||
, turtle >= 1.2.0
|
, turtle >= 1.2.0
|
||||||
, text
|
, text
|
||||||
, QuickCheck >=2.8 && <3.0
|
, QuickCheck >=2.10 && <3.0
|
||||||
other-modules:
|
other-modules:
|
||||||
GeneratedTests
|
GeneratedTests
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
16
nix/QuickCheck.nix
Normal file
16
nix/QuickCheck.nix
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{ mkDerivation, base, containers, deepseq, random, stdenv
|
||||||
|
, template-haskell, tf-random, transformers
|
||||||
|
}:
|
||||||
|
mkDerivation {
|
||||||
|
pname = "QuickCheck";
|
||||||
|
version = "2.10";
|
||||||
|
sha256 = "f6f55b798044ad985cce9c38a3d774b32811a0ffdb2066ca9ed45f32b25de7af";
|
||||||
|
libraryHaskellDepends = [
|
||||||
|
base containers deepseq random template-haskell tf-random
|
||||||
|
transformers
|
||||||
|
];
|
||||||
|
testHaskellDepends = [ base ];
|
||||||
|
homepage = "https://github.com/nick8325/quickcheck";
|
||||||
|
description = "Automatic testing of Haskell programs";
|
||||||
|
license = stdenv.lib.licenses.bsd3;
|
||||||
|
}
|
|
@ -1,38 +1,42 @@
|
||||||
{ mkDerivation, aeson, aeson-pretty, attoparsec, base
|
{ mkDerivation, aeson, aeson-pretty, attoparsec, base
|
||||||
, base64-bytestring, binary, bytestring, cereal, containers
|
, base64-bytestring, binary, bytestring, cereal, containers
|
||||||
, deepseq, doctest, fetchgit, foldl, hashable, haskell-src
|
, contravariant, deepseq, doctest, fetchgit, filepath, foldl
|
||||||
, insert-ordered-containers, lens, mtl, neat-interpolation
|
, hashable, haskell-src, insert-ordered-containers, lens, mtl
|
||||||
, optparse-generic, parsec, parsers, pretty, pretty-show
|
, neat-interpolation, optparse-applicative, optparse-generic
|
||||||
, proto3-wire, QuickCheck, range-set-list, safe, semigroups, stdenv
|
, parsec, parsers, pretty, pretty-show, proto3-wire, QuickCheck
|
||||||
|
, quickcheck-instances, range-set-list, safe, semigroups, stdenv
|
||||||
, swagger2, system-filepath, tasty, tasty-hunit, tasty-quickcheck
|
, swagger2, system-filepath, tasty, tasty-hunit, tasty-quickcheck
|
||||||
, text, transformers, turtle, vector
|
, text, transformers, turtle, vector
|
||||||
}:
|
}:
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
pname = "proto3-suite";
|
pname = "proto3-suite";
|
||||||
version = "0.2.0.0";
|
version = "0.4.0.0";
|
||||||
src = fetchgit {
|
src = fetchgit {
|
||||||
url = "https://github.com/awakesecurity/proto3-suite.git";
|
url = "https://github.com/awakesecurity/proto3-suite.git";
|
||||||
sha256 = "1khix03a4hwaqc192s523rjlsk1iq923ndmrj5myh61fr1fpcbaq";
|
sha256 = "091db048hgcq5idvf5gaiqb6hzbs7g1dz6xjqdx61dw2yxgdm957";
|
||||||
rev = "c103a8c6d3c16515fe2e9ea7f932d54729db2f5f";
|
rev = "973c317b91405a11438e3a21706024bfa3d754df";
|
||||||
|
fetchSubmodules = true;
|
||||||
};
|
};
|
||||||
isLibrary = true;
|
isLibrary = true;
|
||||||
isExecutable = true;
|
isExecutable = true;
|
||||||
enableSeparateDataOutput = true;
|
enableSeparateDataOutput = true;
|
||||||
libraryHaskellDepends = [
|
libraryHaskellDepends = [
|
||||||
aeson aeson-pretty attoparsec base base64-bytestring binary
|
aeson aeson-pretty attoparsec base base64-bytestring binary
|
||||||
bytestring cereal containers deepseq foldl hashable haskell-src
|
bytestring cereal containers contravariant deepseq filepath foldl
|
||||||
insert-ordered-containers lens mtl neat-interpolation parsec
|
hashable haskell-src insert-ordered-containers lens mtl
|
||||||
parsers pretty pretty-show proto3-wire QuickCheck safe semigroups
|
neat-interpolation parsec parsers pretty pretty-show proto3-wire
|
||||||
swagger2 system-filepath text transformers turtle vector
|
QuickCheck quickcheck-instances safe semigroups swagger2
|
||||||
|
system-filepath text transformers turtle vector
|
||||||
];
|
];
|
||||||
executableHaskellDepends = [
|
executableHaskellDepends = [
|
||||||
base containers optparse-generic proto3-wire range-set-list
|
base containers mtl optparse-applicative optparse-generic
|
||||||
system-filepath text turtle
|
proto3-wire range-set-list system-filepath text turtle
|
||||||
];
|
];
|
||||||
testHaskellDepends = [
|
testHaskellDepends = [
|
||||||
aeson attoparsec base base64-bytestring bytestring cereal doctest
|
aeson attoparsec base base64-bytestring bytestring cereal
|
||||||
pretty-show proto3-wire QuickCheck semigroups swagger2 tasty
|
containers deepseq doctest mtl pretty-show proto3-wire QuickCheck
|
||||||
tasty-hunit tasty-quickcheck text transformers turtle vector
|
semigroups swagger2 tasty tasty-hunit tasty-quickcheck 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;
|
||||||
|
|
22
nix/quickcheck-instances.nix
Normal file
22
nix/quickcheck-instances.nix
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{ mkDerivation, array, base, base-compat, bytestring
|
||||||
|
, case-insensitive, containers, hashable, old-time, QuickCheck
|
||||||
|
, scientific, stdenv, tagged, text, time, transformers
|
||||||
|
, transformers-compat, unordered-containers, uuid-types, vector
|
||||||
|
}:
|
||||||
|
mkDerivation {
|
||||||
|
pname = "quickcheck-instances";
|
||||||
|
version = "0.3.15";
|
||||||
|
sha256 = "9e0efd0debe1fe390c97d7b3d80d59f3221f2ff4aa1649a1929b4a118156dc0a";
|
||||||
|
libraryHaskellDepends = [
|
||||||
|
array base base-compat bytestring case-insensitive containers
|
||||||
|
hashable old-time QuickCheck scientific tagged text time
|
||||||
|
transformers transformers-compat unordered-containers uuid-types
|
||||||
|
vector
|
||||||
|
];
|
||||||
|
testHaskellDepends = [
|
||||||
|
base containers QuickCheck tagged uuid-types
|
||||||
|
];
|
||||||
|
homepage = "https://github.com/phadej/qc-instances";
|
||||||
|
description = "Common quickcheck instances";
|
||||||
|
license = stdenv.lib.licenses.bsd3;
|
||||||
|
}
|
15
release.nix
15
release.nix
|
@ -189,6 +189,9 @@ let
|
||||||
|
|
||||||
haskellPackages = pkgs.haskellPackages.override {
|
haskellPackages = pkgs.haskellPackages.override {
|
||||||
overrides = haskellPackagesNew: haskellPackagesOld: rec {
|
overrides = haskellPackagesNew: haskellPackagesOld: rec {
|
||||||
|
attoparsec =
|
||||||
|
pkgs.haskell.lib.dontCheck haskellPackagesOld.attoparsec;
|
||||||
|
|
||||||
aeson =
|
aeson =
|
||||||
pkgs.haskell.lib.dontCheck
|
pkgs.haskell.lib.dontCheck
|
||||||
(haskellPackagesNew.callPackage ./nix/aeson.nix {});
|
(haskellPackagesNew.callPackage ./nix/aeson.nix {});
|
||||||
|
@ -196,6 +199,12 @@ let
|
||||||
cabal-doctest =
|
cabal-doctest =
|
||||||
haskellPackagesNew.callPackage ./nix/cabal-doctest.nix { };
|
haskellPackagesNew.callPackage ./nix/cabal-doctest.nix { };
|
||||||
|
|
||||||
|
edit-distance =
|
||||||
|
pkgs.haskell.lib.dontCheck haskellPackagesOld.edit-distance;
|
||||||
|
|
||||||
|
http-media =
|
||||||
|
pkgs.haskell.lib.dontCheck haskellPackagesOld.http-media;
|
||||||
|
|
||||||
insert-ordered-containers =
|
insert-ordered-containers =
|
||||||
haskellPackagesNew.callPackage ./nix/insert-ordered-containers.nix { };
|
haskellPackagesNew.callPackage ./nix/insert-ordered-containers.nix { };
|
||||||
|
|
||||||
|
@ -212,6 +221,12 @@ let
|
||||||
pkgs.haskell.lib.dontCheck
|
pkgs.haskell.lib.dontCheck
|
||||||
(haskellPackagesNew.callPackage ./nix/proto3-suite.nix {});
|
(haskellPackagesNew.callPackage ./nix/proto3-suite.nix {});
|
||||||
|
|
||||||
|
QuickCheck =
|
||||||
|
(haskellPackagesNew.callPackage ./nix/QuickCheck.nix {});
|
||||||
|
|
||||||
|
quickcheck-instances =
|
||||||
|
(haskellPackagesNew.callPackage ./nix/quickcheck-instances.nix {});
|
||||||
|
|
||||||
grpc-haskell-core =
|
grpc-haskell-core =
|
||||||
usesGRPC
|
usesGRPC
|
||||||
(pkgs.haskell.lib.overrideCabal
|
(pkgs.haskell.lib.overrideCabal
|
||||||
|
|
|
@ -21,7 +21,13 @@ testServerGeneration = testCase "server generation" $ do
|
||||||
mktree hsTmpDir
|
mktree hsTmpDir
|
||||||
mktree pyTmpDir
|
mktree pyTmpDir
|
||||||
|
|
||||||
compileDotProtoFileOrDie [] hsTmpDir ["tests"] "simple.proto"
|
let args = CompileArgs
|
||||||
|
{ includeDir = ["tests"]
|
||||||
|
, extraInstanceFiles = []
|
||||||
|
, inputProto = "simple.proto"
|
||||||
|
, outputDir = hsTmpDir
|
||||||
|
}
|
||||||
|
compileDotProtoFileOrDie args
|
||||||
|
|
||||||
do exitCode <- proc "tests/simple-server.sh" [hsTmpDir] empty
|
do exitCode <- proc "tests/simple-server.sh" [hsTmpDir] empty
|
||||||
exitCode @?= ExitSuccess
|
exitCode @?= ExitSuccess
|
||||||
|
@ -49,7 +55,13 @@ testClientGeneration = testCase "client generation" $ do
|
||||||
mktree hsTmpDir
|
mktree hsTmpDir
|
||||||
mktree pyTmpDir
|
mktree pyTmpDir
|
||||||
|
|
||||||
compileDotProtoFileOrDie [] hsTmpDir ["tests"] "simple.proto"
|
let args = CompileArgs
|
||||||
|
{ includeDir = ["tests"]
|
||||||
|
, extraInstanceFiles = []
|
||||||
|
, inputProto = "simple.proto"
|
||||||
|
, outputDir = hsTmpDir
|
||||||
|
}
|
||||||
|
compileDotProtoFileOrDie args
|
||||||
|
|
||||||
do exitCode <- proc "tests/simple-client.sh" [hsTmpDir] empty
|
do exitCode <- proc "tests/simple-client.sh" [hsTmpDir] empty
|
||||||
exitCode @?= ExitSuccess
|
exitCode @?= ExitSuccess
|
||||||
|
|
|
@ -34,7 +34,7 @@ import Test.Tasty
|
||||||
import Test.Tasty.HUnit ((@?=), assertString, testCase)
|
import Test.Tasty.HUnit ((@?=), assertString, testCase)
|
||||||
|
|
||||||
testNormalCall client = testCase "Normal call" $
|
testNormalCall client = testCase "Normal call" $
|
||||||
do randoms <- fromList <$> replicateM 1000 (Fixed <$> randomRIO (1, 1000))
|
do randoms <- fromList <$> replicateM 1000 (randomRIO (1, 1000))
|
||||||
let req = SimpleServiceRequest "NormalRequest" randoms
|
let req = SimpleServiceRequest "NormalRequest" randoms
|
||||||
res <- simpleServiceNormalCall client
|
res <- simpleServiceNormalCall client
|
||||||
(ClientNormalRequest req 10 mempty)
|
(ClientNormalRequest req 10 mempty)
|
||||||
|
@ -52,7 +52,7 @@ testClientStreamingCall client = testCase "Client-streaming call" $
|
||||||
do (finalName, totalSum) <-
|
do (finalName, totalSum) <-
|
||||||
fmap ((mconcat *** (sum . mconcat)) . unzip) .
|
fmap ((mconcat *** (sum . mconcat)) . unzip) .
|
||||||
replicateM iterationCount $
|
replicateM iterationCount $
|
||||||
do randoms <- fromList <$> replicateM 1000 (Fixed <$> randomRIO (1, 1000))
|
do randoms <- fromList <$> replicateM 1000 (randomRIO (1, 1000))
|
||||||
name <- fromString <$> replicateM 10 (randomRIO ('a', 'z'))
|
name <- fromString <$> replicateM 10 (randomRIO ('a', 'z'))
|
||||||
send (SimpleServiceRequest name randoms)
|
send (SimpleServiceRequest name randoms)
|
||||||
pure (name, randoms)
|
pure (name, randoms)
|
||||||
|
@ -69,7 +69,7 @@ testClientStreamingCall client = testCase "Client-streaming call" $
|
||||||
|
|
||||||
testServerStreamingCall client = testCase "Server-streaming call" $
|
testServerStreamingCall client = testCase "Server-streaming call" $
|
||||||
do numCount <- randomRIO (50, 500)
|
do numCount <- randomRIO (50, 500)
|
||||||
nums <- replicateM numCount (Fixed <$> randomIO)
|
nums <- replicateM numCount randomIO
|
||||||
|
|
||||||
let checkResults [] recv =
|
let checkResults [] recv =
|
||||||
do res <- recv
|
do res <- recv
|
||||||
|
@ -98,7 +98,7 @@ testBiDiStreamingCall client = testCase "Bidi-streaming call" $
|
||||||
do let handleRequests (0 :: Int) _ _ done = done >> pure ()
|
do let handleRequests (0 :: Int) _ _ done = done >> pure ()
|
||||||
handleRequests n recv send done =
|
handleRequests n recv send done =
|
||||||
do numCount <- randomRIO (10, 1000)
|
do numCount <- randomRIO (10, 1000)
|
||||||
nums <- fromList <$> replicateM numCount (Fixed <$> randomRIO (1, 1000))
|
nums <- fromList <$> replicateM numCount (randomRIO (1, 1000))
|
||||||
testName <- fromString <$> replicateM 10 (randomRIO ('a', 'z'))
|
testName <- fromString <$> replicateM 10 (randomRIO ('a', 'z'))
|
||||||
send (SimpleServiceRequest testName nums)
|
send (SimpleServiceRequest testName nums)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue