mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-11-23 03:29:42 +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
|
||||||
|
|
44
examples/echo/echo-hs/Echo.hs
generated
44
examples/echo/echo-hs/Echo.hs
generated
|
@ -32,12 +32,12 @@ import Network.GRPC.HighLevel.Client as HsGRPC
|
||||||
import Network.GRPC.HighLevel.Server as HsGRPC hiding (serverLoop)
|
import Network.GRPC.HighLevel.Server as HsGRPC hiding (serverLoop)
|
||||||
import Network.GRPC.HighLevel.Server.Unregistered as HsGRPC
|
import Network.GRPC.HighLevel.Server.Unregistered as HsGRPC
|
||||||
(serverLoop)
|
(serverLoop)
|
||||||
|
|
||||||
data Echo request response = Echo{echoDoEcho ::
|
data Echo request response = Echo{echoDoEcho ::
|
||||||
request 'HsGRPC.Normal Echo.EchoRequest Echo.EchoResponse ->
|
request 'HsGRPC.Normal Echo.EchoRequest Echo.EchoResponse ->
|
||||||
Hs.IO (response 'HsGRPC.Normal Echo.EchoResponse)}
|
Hs.IO (response 'HsGRPC.Normal Echo.EchoResponse)}
|
||||||
deriving Hs.Generic
|
deriving Hs.Generic
|
||||||
|
|
||||||
echoServer ::
|
echoServer ::
|
||||||
Echo HsGRPC.ServerRequest HsGRPC.ServerResponse ->
|
Echo HsGRPC.ServerRequest HsGRPC.ServerResponse ->
|
||||||
HsGRPC.ServiceOptions -> Hs.IO ()
|
HsGRPC.ServiceOptions -> Hs.IO ()
|
||||||
|
@ -56,7 +56,7 @@ echoServer Echo{echoDoEcho = echoDoEcho}
|
||||||
optUserAgentSuffix = userAgentSuffix,
|
optUserAgentSuffix = userAgentSuffix,
|
||||||
optInitialMetadata = initialMetadata, optSSLConfig = sslConfig,
|
optInitialMetadata = initialMetadata, optSSLConfig = sslConfig,
|
||||||
optLogger = logger})
|
optLogger = logger})
|
||||||
|
|
||||||
echoClient ::
|
echoClient ::
|
||||||
HsGRPC.Client ->
|
HsGRPC.Client ->
|
||||||
Hs.IO (Echo HsGRPC.ClientRequest HsGRPC.ClientResult)
|
Hs.IO (Echo HsGRPC.ClientRequest HsGRPC.ClientResult)
|
||||||
|
@ -65,13 +65,13 @@ echoClient client
|
||||||
((Hs.pure (HsGRPC.clientRequest client)) <*>
|
((Hs.pure (HsGRPC.clientRequest client)) <*>
|
||||||
(HsGRPC.clientRegisterMethod client
|
(HsGRPC.clientRegisterMethod client
|
||||||
(HsGRPC.MethodName "/echo.Echo/DoEcho")))
|
(HsGRPC.MethodName "/echo.Echo/DoEcho")))
|
||||||
|
|
||||||
data EchoRequest = EchoRequest{echoRequestMessage :: Hs.Text}
|
data EchoRequest = EchoRequest{echoRequestMessage :: Hs.Text}
|
||||||
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic)
|
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic)
|
||||||
|
|
||||||
instance HsProtobuf.Named EchoRequest where
|
instance HsProtobuf.Named EchoRequest where
|
||||||
nameOf _ = (Hs.fromString "EchoRequest")
|
nameOf _ = (Hs.fromString "EchoRequest")
|
||||||
|
|
||||||
instance HsProtobuf.Message EchoRequest where
|
instance HsProtobuf.Message EchoRequest where
|
||||||
encodeMessage _
|
encodeMessage _
|
||||||
EchoRequest{echoRequestMessage = echoRequestMessage}
|
EchoRequest{echoRequestMessage = echoRequestMessage}
|
||||||
|
@ -87,24 +87,24 @@ 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])
|
||||||
toEncodingPB (EchoRequest f1) = (HsJSONPB.pairs ["message" .= f1])
|
toEncodingPB (EchoRequest f1) = (HsJSONPB.pairs ["message" .= f1])
|
||||||
|
|
||||||
instance HsJSONPB.FromJSONPB EchoRequest where
|
instance HsJSONPB.FromJSONPB EchoRequest where
|
||||||
parseJSONPB
|
parseJSONPB
|
||||||
= (HsJSONPB.withObject "EchoRequest"
|
= (HsJSONPB.withObject "EchoRequest"
|
||||||
(\ obj -> (Hs.pure EchoRequest) <*> obj .: "message"))
|
(\ obj -> (Hs.pure EchoRequest) <*> obj .: "message"))
|
||||||
|
|
||||||
instance HsJSONPB.ToJSON EchoRequest where
|
instance HsJSONPB.ToJSON EchoRequest where
|
||||||
toJSON = HsJSONPB.toAesonValue
|
toJSON = HsJSONPB.toAesonValue
|
||||||
toEncoding = HsJSONPB.toAesonEncoding
|
toEncoding = HsJSONPB.toAesonEncoding
|
||||||
|
|
||||||
instance HsJSONPB.FromJSON EchoRequest where
|
instance HsJSONPB.FromJSON EchoRequest where
|
||||||
parseJSON = HsJSONPB.parseJSONPB
|
parseJSON = HsJSONPB.parseJSONPB
|
||||||
|
|
||||||
instance HsJSONPB.ToSchema EchoRequest where
|
instance HsJSONPB.ToSchema EchoRequest where
|
||||||
declareNamedSchema _
|
declareNamedSchema _
|
||||||
= do let declare_message = HsJSONPB.declareSchemaRef
|
= do let declare_message = HsJSONPB.declareSchemaRef
|
||||||
|
@ -120,13 +120,13 @@ instance HsJSONPB.ToSchema EchoRequest where
|
||||||
HsJSONPB._schemaProperties =
|
HsJSONPB._schemaProperties =
|
||||||
HsJSONPB.insOrdFromList
|
HsJSONPB.insOrdFromList
|
||||||
[("message", echoRequestMessage)]}})
|
[("message", echoRequestMessage)]}})
|
||||||
|
|
||||||
data EchoResponse = EchoResponse{echoResponseMessage :: Hs.Text}
|
data EchoResponse = EchoResponse{echoResponseMessage :: Hs.Text}
|
||||||
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic)
|
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic)
|
||||||
|
|
||||||
instance HsProtobuf.Named EchoResponse where
|
instance HsProtobuf.Named EchoResponse where
|
||||||
nameOf _ = (Hs.fromString "EchoResponse")
|
nameOf _ = (Hs.fromString "EchoResponse")
|
||||||
|
|
||||||
instance HsProtobuf.Message EchoResponse where
|
instance HsProtobuf.Message EchoResponse where
|
||||||
encodeMessage _
|
encodeMessage _
|
||||||
EchoResponse{echoResponseMessage = echoResponseMessage}
|
EchoResponse{echoResponseMessage = echoResponseMessage}
|
||||||
|
@ -142,24 +142,24 @@ 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])
|
||||||
toEncodingPB (EchoResponse f1) = (HsJSONPB.pairs ["message" .= f1])
|
toEncodingPB (EchoResponse f1) = (HsJSONPB.pairs ["message" .= f1])
|
||||||
|
|
||||||
instance HsJSONPB.FromJSONPB EchoResponse where
|
instance HsJSONPB.FromJSONPB EchoResponse where
|
||||||
parseJSONPB
|
parseJSONPB
|
||||||
= (HsJSONPB.withObject "EchoResponse"
|
= (HsJSONPB.withObject "EchoResponse"
|
||||||
(\ obj -> (Hs.pure EchoResponse) <*> obj .: "message"))
|
(\ obj -> (Hs.pure EchoResponse) <*> obj .: "message"))
|
||||||
|
|
||||||
instance HsJSONPB.ToJSON EchoResponse where
|
instance HsJSONPB.ToJSON EchoResponse where
|
||||||
toJSON = HsJSONPB.toAesonValue
|
toJSON = HsJSONPB.toAesonValue
|
||||||
toEncoding = HsJSONPB.toAesonEncoding
|
toEncoding = HsJSONPB.toAesonEncoding
|
||||||
|
|
||||||
instance HsJSONPB.FromJSON EchoResponse where
|
instance HsJSONPB.FromJSON EchoResponse where
|
||||||
parseJSON = HsJSONPB.parseJSONPB
|
parseJSON = HsJSONPB.parseJSONPB
|
||||||
|
|
||||||
instance HsJSONPB.ToSchema EchoResponse where
|
instance HsJSONPB.ToSchema EchoResponse where
|
||||||
declareNamedSchema _
|
declareNamedSchema _
|
||||||
= do let declare_message = HsJSONPB.declareSchemaRef
|
= do let declare_message = HsJSONPB.declareSchemaRef
|
||||||
|
@ -174,4 +174,4 @@ instance HsJSONPB.ToSchema EchoResponse where
|
||||||
HsJSONPB.SwaggerObject},
|
HsJSONPB.SwaggerObject},
|
||||||
HsJSONPB._schemaProperties =
|
HsJSONPB._schemaProperties =
|
||||||
HsJSONPB.insOrdFromList
|
HsJSONPB.insOrdFromList
|
||||||
[("message", echoResponseMessage)]}})
|
[("message", echoResponseMessage)]}})
|
||||||
|
|
|
@ -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)
|
||||||
|
|
46
examples/tutorial/Arithmetic.hs
generated
46
examples/tutorial/Arithmetic.hs
generated
|
@ -32,7 +32,7 @@ import Network.GRPC.HighLevel.Client as HsGRPC
|
||||||
import Network.GRPC.HighLevel.Server as HsGRPC hiding (serverLoop)
|
import Network.GRPC.HighLevel.Server as HsGRPC hiding (serverLoop)
|
||||||
import Network.GRPC.HighLevel.Server.Unregistered as HsGRPC
|
import Network.GRPC.HighLevel.Server.Unregistered as HsGRPC
|
||||||
(serverLoop)
|
(serverLoop)
|
||||||
|
|
||||||
data Arithmetic request response = Arithmetic{arithmeticAdd ::
|
data Arithmetic request response = Arithmetic{arithmeticAdd ::
|
||||||
request 'HsGRPC.Normal Arithmetic.TwoInts
|
request 'HsGRPC.Normal Arithmetic.TwoInts
|
||||||
Arithmetic.OneInt
|
Arithmetic.OneInt
|
||||||
|
@ -46,7 +46,7 @@ data Arithmetic request response = Arithmetic{arithmeticAdd ::
|
||||||
(response 'HsGRPC.ClientStreaming
|
(response 'HsGRPC.ClientStreaming
|
||||||
Arithmetic.OneInt)}
|
Arithmetic.OneInt)}
|
||||||
deriving Hs.Generic
|
deriving Hs.Generic
|
||||||
|
|
||||||
arithmeticServer ::
|
arithmeticServer ::
|
||||||
Arithmetic HsGRPC.ServerRequest HsGRPC.ServerResponse ->
|
Arithmetic HsGRPC.ServerRequest HsGRPC.ServerResponse ->
|
||||||
HsGRPC.ServiceOptions -> Hs.IO ()
|
HsGRPC.ServiceOptions -> Hs.IO ()
|
||||||
|
@ -72,7 +72,7 @@ arithmeticServer
|
||||||
optUserAgentSuffix = userAgentSuffix,
|
optUserAgentSuffix = userAgentSuffix,
|
||||||
optInitialMetadata = initialMetadata, optSSLConfig = sslConfig,
|
optInitialMetadata = initialMetadata, optSSLConfig = sslConfig,
|
||||||
optLogger = logger})
|
optLogger = logger})
|
||||||
|
|
||||||
arithmeticClient ::
|
arithmeticClient ::
|
||||||
HsGRPC.Client ->
|
HsGRPC.Client ->
|
||||||
Hs.IO (Arithmetic HsGRPC.ClientRequest HsGRPC.ClientResult)
|
Hs.IO (Arithmetic HsGRPC.ClientRequest HsGRPC.ClientResult)
|
||||||
|
@ -85,13 +85,13 @@ arithmeticClient client
|
||||||
((Hs.pure (HsGRPC.clientRequest client)) <*>
|
((Hs.pure (HsGRPC.clientRequest client)) <*>
|
||||||
(HsGRPC.clientRegisterMethod client
|
(HsGRPC.clientRegisterMethod client
|
||||||
(HsGRPC.MethodName "/arithmetic.Arithmetic/RunningSum")))
|
(HsGRPC.MethodName "/arithmetic.Arithmetic/RunningSum")))
|
||||||
|
|
||||||
data TwoInts = TwoInts{twoIntsX :: Hs.Int32, twoIntsY :: Hs.Int32}
|
data TwoInts = TwoInts{twoIntsX :: Hs.Int32, twoIntsY :: Hs.Int32}
|
||||||
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic)
|
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic)
|
||||||
|
|
||||||
instance HsProtobuf.Named TwoInts where
|
instance HsProtobuf.Named TwoInts where
|
||||||
nameOf _ = (Hs.fromString "TwoInts")
|
nameOf _ = (Hs.fromString "TwoInts")
|
||||||
|
|
||||||
instance HsProtobuf.Message TwoInts where
|
instance HsProtobuf.Message TwoInts where
|
||||||
encodeMessage _ TwoInts{twoIntsX = twoIntsX, twoIntsY = twoIntsY}
|
encodeMessage _ TwoInts{twoIntsX = twoIntsX, twoIntsY = twoIntsY}
|
||||||
= (Hs.mconcat
|
= (Hs.mconcat
|
||||||
|
@ -111,30 +111,30 @@ 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])
|
||||||
toEncodingPB (TwoInts f1 f2)
|
toEncodingPB (TwoInts f1 f2)
|
||||||
= (HsJSONPB.pairs ["x" .= f1, "y" .= f2])
|
= (HsJSONPB.pairs ["x" .= f1, "y" .= f2])
|
||||||
|
|
||||||
instance HsJSONPB.FromJSONPB TwoInts where
|
instance HsJSONPB.FromJSONPB TwoInts where
|
||||||
parseJSONPB
|
parseJSONPB
|
||||||
= (HsJSONPB.withObject "TwoInts"
|
= (HsJSONPB.withObject "TwoInts"
|
||||||
(\ obj -> (Hs.pure TwoInts) <*> obj .: "x" <*> obj .: "y"))
|
(\ obj -> (Hs.pure TwoInts) <*> obj .: "x" <*> obj .: "y"))
|
||||||
|
|
||||||
instance HsJSONPB.ToJSON TwoInts where
|
instance HsJSONPB.ToJSON TwoInts where
|
||||||
toJSON = HsJSONPB.toAesonValue
|
toJSON = HsJSONPB.toAesonValue
|
||||||
toEncoding = HsJSONPB.toAesonEncoding
|
toEncoding = HsJSONPB.toAesonEncoding
|
||||||
|
|
||||||
instance HsJSONPB.FromJSON TwoInts where
|
instance HsJSONPB.FromJSON TwoInts where
|
||||||
parseJSON = HsJSONPB.parseJSONPB
|
parseJSON = HsJSONPB.parseJSONPB
|
||||||
|
|
||||||
instance HsJSONPB.ToSchema TwoInts where
|
instance HsJSONPB.ToSchema TwoInts where
|
||||||
declareNamedSchema _
|
declareNamedSchema _
|
||||||
= do let declare_x = HsJSONPB.declareSchemaRef
|
= do let declare_x = HsJSONPB.declareSchemaRef
|
||||||
|
@ -153,13 +153,13 @@ instance HsJSONPB.ToSchema TwoInts where
|
||||||
HsJSONPB._schemaProperties =
|
HsJSONPB._schemaProperties =
|
||||||
HsJSONPB.insOrdFromList
|
HsJSONPB.insOrdFromList
|
||||||
[("x", twoIntsX), ("y", twoIntsY)]}})
|
[("x", twoIntsX), ("y", twoIntsY)]}})
|
||||||
|
|
||||||
data OneInt = OneInt{oneIntResult :: Hs.Int32}
|
data OneInt = OneInt{oneIntResult :: Hs.Int32}
|
||||||
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic)
|
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic)
|
||||||
|
|
||||||
instance HsProtobuf.Named OneInt where
|
instance HsProtobuf.Named OneInt where
|
||||||
nameOf _ = (Hs.fromString "OneInt")
|
nameOf _ = (Hs.fromString "OneInt")
|
||||||
|
|
||||||
instance HsProtobuf.Message OneInt where
|
instance HsProtobuf.Message OneInt where
|
||||||
encodeMessage _ OneInt{oneIntResult = oneIntResult}
|
encodeMessage _ OneInt{oneIntResult = oneIntResult}
|
||||||
= (Hs.mconcat
|
= (Hs.mconcat
|
||||||
|
@ -174,24 +174,24 @@ 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])
|
||||||
toEncodingPB (OneInt f1) = (HsJSONPB.pairs ["result" .= f1])
|
toEncodingPB (OneInt f1) = (HsJSONPB.pairs ["result" .= f1])
|
||||||
|
|
||||||
instance HsJSONPB.FromJSONPB OneInt where
|
instance HsJSONPB.FromJSONPB OneInt where
|
||||||
parseJSONPB
|
parseJSONPB
|
||||||
= (HsJSONPB.withObject "OneInt"
|
= (HsJSONPB.withObject "OneInt"
|
||||||
(\ obj -> (Hs.pure OneInt) <*> obj .: "result"))
|
(\ obj -> (Hs.pure OneInt) <*> obj .: "result"))
|
||||||
|
|
||||||
instance HsJSONPB.ToJSON OneInt where
|
instance HsJSONPB.ToJSON OneInt where
|
||||||
toJSON = HsJSONPB.toAesonValue
|
toJSON = HsJSONPB.toAesonValue
|
||||||
toEncoding = HsJSONPB.toAesonEncoding
|
toEncoding = HsJSONPB.toAesonEncoding
|
||||||
|
|
||||||
instance HsJSONPB.FromJSON OneInt where
|
instance HsJSONPB.FromJSON OneInt where
|
||||||
parseJSON = HsJSONPB.parseJSONPB
|
parseJSON = HsJSONPB.parseJSONPB
|
||||||
|
|
||||||
instance HsJSONPB.ToSchema OneInt where
|
instance HsJSONPB.ToSchema OneInt where
|
||||||
declareNamedSchema _
|
declareNamedSchema _
|
||||||
= do let declare_result = HsJSONPB.declareSchemaRef
|
= do let declare_result = HsJSONPB.declareSchemaRef
|
||||||
|
@ -205,4 +205,4 @@ instance HsJSONPB.ToSchema OneInt where
|
||||||
HsJSONPB.SwaggerObject},
|
HsJSONPB.SwaggerObject},
|
||||||
HsJSONPB._schemaProperties =
|
HsJSONPB._schemaProperties =
|
||||||
HsJSONPB.insOrdFromList
|
HsJSONPB.insOrdFromList
|
||||||
[("result", oneIntResult)]}})
|
[("result", oneIntResult)]}})
|
||||||
|
|
|
@ -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