diff --git a/core/grpc-haskell-core.cabal b/core/grpc-haskell-core.cabal index e134200..dabc5b4 100644 --- a/core/grpc-haskell-core.cabal +++ b/core/grpc-haskell-core.cabal @@ -1,5 +1,5 @@ name: grpc-haskell-core -version: 0.2.0 +version: 0.3.0 synopsis: Haskell implementation of gRPC layered on shared C library. homepage: https://github.com/awakenetworks/gRPC-haskell license: Apache-2.0 diff --git a/examples/echo/echo-hs/Echo.hs b/examples/echo/echo-hs/Echo.hs index aa60450..5c269f3 100644 --- a/examples/echo/echo-hs/Echo.hs +++ b/examples/echo/echo-hs/Echo.hs @@ -4,12 +4,12 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE OverloadedStrings #-} -{-# OPTIONS_GHC -fno-warn-unused-imports #-} -{-# OPTIONS_GHC -fno-warn-name-shadowing #-} -{-# OPTIONS_GHC -fno-warn-unused-matches #-} +{-# OPTIONS_GHC -fno-warn-unused-imports #-} +{-# OPTIONS_GHC -fno-warn-name-shadowing #-} +{-# OPTIONS_GHC -fno-warn-unused-matches #-} +{-# OPTIONS_GHC -fno-warn-missing-export-lists #-} -- | Generated by Haskell protocol buffer compiler. DO NOT EDIT! - module Echo where import qualified Prelude as Hs import qualified Proto3.Suite.Class as HsProtobuf @@ -52,7 +52,7 @@ echoServer :: echoServer Echo{echoDoEcho = echoDoEcho} (ServiceOptions serverHost serverPort useCompression userAgentPrefix userAgentSuffix initialMetadata sslConfig logger - serverMaxReceiveMessageLength) + serverMaxReceiveMessageLength serverMaxMetadataSize) = (HsGRPC.serverLoop HsGRPC.defaultOptions{HsGRPC.optNormalHandlers = [(HsGRPC.UnaryHandler (HsGRPC.MethodName "/echo.Echo/DoEcho") @@ -65,7 +65,8 @@ echoServer Echo{echoDoEcho = echoDoEcho} optUserAgentSuffix = userAgentSuffix, optInitialMetadata = initialMetadata, optSSLConfig = sslConfig, optLogger = logger, - optMaxReceiveMessageLength = serverMaxReceiveMessageLength}) + optMaxReceiveMessageLength = serverMaxReceiveMessageLength, + optMaxMetadataSize = serverMaxMetadataSize}) echoClient :: HsGRPC.Client -> diff --git a/examples/tutorial/Arithmetic.hs b/examples/tutorial/Arithmetic.hs index 520957a..c99e514 100644 --- a/examples/tutorial/Arithmetic.hs +++ b/examples/tutorial/Arithmetic.hs @@ -4,12 +4,12 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE OverloadedStrings #-} -{-# OPTIONS_GHC -fno-warn-unused-imports #-} -{-# OPTIONS_GHC -fno-warn-name-shadowing #-} -{-# OPTIONS_GHC -fno-warn-unused-matches #-} +{-# OPTIONS_GHC -fno-warn-unused-imports #-} +{-# OPTIONS_GHC -fno-warn-name-shadowing #-} +{-# OPTIONS_GHC -fno-warn-unused-matches #-} +{-# OPTIONS_GHC -fno-warn-missing-export-lists #-} -- | Generated by Haskell protocol buffer compiler. DO NOT EDIT! - module Arithmetic where import qualified Prelude as Hs import qualified Proto3.Suite.Class as HsProtobuf @@ -63,7 +63,7 @@ arithmeticServer arithmeticRunningSum = arithmeticRunningSum} (ServiceOptions serverHost serverPort useCompression userAgentPrefix userAgentSuffix initialMetadata sslConfig logger - serverMaxReceiveMessageLength) + serverMaxReceiveMessageLength serverMaxMetadataSize) = (HsGRPC.serverLoop HsGRPC.defaultOptions{HsGRPC.optNormalHandlers = [(HsGRPC.UnaryHandler @@ -81,7 +81,8 @@ arithmeticServer optUserAgentSuffix = userAgentSuffix, optInitialMetadata = initialMetadata, optSSLConfig = sslConfig, optLogger = logger, - optMaxReceiveMessageLength = serverMaxReceiveMessageLength}) + optMaxReceiveMessageLength = serverMaxReceiveMessageLength, + optMaxMetadataSize = serverMaxMetadataSize}) arithmeticClient :: HsGRPC.Client -> diff --git a/grpc-haskell.cabal b/grpc-haskell.cabal index 4a5a8bd..4863c9f 100644 --- a/grpc-haskell.cabal +++ b/grpc-haskell.cabal @@ -1,5 +1,5 @@ name: grpc-haskell -version: 0.2.0 +version: 0.3.0 synopsis: Haskell implementation of gRPC layered on shared C library. homepage: https://github.com/awakenetworks/gRPC-haskell license: Apache-2.0 @@ -29,9 +29,9 @@ library build-depends: base >=4.8 && <5.0 , bytestring ==0.10.* - , proto3-suite >=0.4.1 - , proto3-wire >=1.2.0 - , grpc-haskell-core >=0.2.0 + , proto3-suite >=0.4.3 + , proto3-wire >=1.2.2 + , grpc-haskell-core >=0.2.1 , async >=2.1 && <2.3 , managed >= 1.0.5 diff --git a/nix/proto3-suite.nix b/nix/proto3-suite.nix index b334e35..ce96ae4 100644 --- a/nix/proto3-suite.nix +++ b/nix/proto3-suite.nix @@ -2,19 +2,20 @@ , base64-bytestring, binary, bytestring, cereal, containers , contravariant, deepseq, doctest, fetchgit, filepath, foldl , generic-arbitrary, hashable, haskell-src -, insert-ordered-containers, lens, mtl, neat-interpolation +, insert-ordered-containers, lens, lib, mtl, neat-interpolation , optparse-applicative, optparse-generic, parsec, parsers, pretty , pretty-show, proto3-wire, QuickCheck, quickcheck-instances -, range-set-list, safe, stdenv, swagger2, system-filepath, tasty -, tasty-hunit, tasty-quickcheck, text, transformers, turtle, vector +, range-set-list, safe, swagger2, system-filepath, tasty +, tasty-hunit, tasty-quickcheck, text, time, transformers, turtle +, vector }: mkDerivation { pname = "proto3-suite"; - version = "0.4.2.0"; + version = "0.4.3"; src = fetchgit { url = "https://github.com/awakesecurity/proto3-suite.git"; - sha256 = "0mpy35r6qd1v5sixhy2lqcn5x81rfj4dc079g1kpa4fb1f23dbha"; - rev = "0af901f9ef3b9719e08eae4fab8fd700d6c8047a"; + sha256 = "0bjqczi6wddxv0n7qmfbrr19ajgq66xdkxx8vfcgbmv8ygma3vlw"; + rev = "7af7d76dcf9cc71ddada3aa4a38abf46f65550ca"; fetchSubmodules = true; }; isLibrary = true; @@ -26,7 +27,7 @@ mkDerivation { hashable haskell-src insert-ordered-containers lens mtl neat-interpolation parsec parsers pretty pretty-show proto3-wire QuickCheck quickcheck-instances safe swagger2 system-filepath text - transformers turtle vector + time transformers turtle vector ]; executableHaskellDepends = [ base containers mtl optparse-applicative optparse-generic @@ -38,6 +39,6 @@ mkDerivation { proto3-wire QuickCheck 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"; - license = stdenv.lib.licenses.asl20; + description = "A higher-level API to the proto3-wire library"; + license = lib.licenses.asl20; } diff --git a/nix/proto3-wire.nix b/nix/proto3-wire.nix index 2522d7f..4017955 100644 --- a/nix/proto3-wire.nix +++ b/nix/proto3-wire.nix @@ -1,17 +1,12 @@ { mkDerivation, base, bytestring, cereal, containers, deepseq -, doctest, fetchgit, ghc-prim, hashable, parameterized, primitive -, QuickCheck, safe, stdenv, tasty, tasty-hunit, tasty-quickcheck -, text, transformers, unordered-containers, vector +, doctest, ghc-prim, hashable, lib, parameterized, primitive +, QuickCheck, safe, tasty, tasty-hunit, tasty-quickcheck, text +, transformers, unordered-containers, vector }: mkDerivation { pname = "proto3-wire"; - version = "1.2.0"; - src = fetchgit { - url = "https://github.com/awakesecurity/proto3-wire.git"; - sha256 = "062b05ab8icwjxaqrh3wmg8s26m620pigqj3dj6rdx9qas1cq6mi"; - rev = "d92ec32ef0f15842b07fb226d8f2d15f36c5fb20"; - fetchSubmodules = true; - }; + version = "1.2.2"; + sha256 = "8d409536a89a0187f0576711966d2ef45d43acab7b6a3a1c5ee12f6d01adbfb9"; libraryHaskellDepends = [ base bytestring cereal containers deepseq ghc-prim hashable parameterized primitive QuickCheck safe text transformers @@ -22,5 +17,5 @@ mkDerivation { tasty-quickcheck text transformers vector ]; description = "A low-level implementation of the Protocol Buffers (version 3) wire format"; - license = stdenv.lib.licenses.asl20; + license = lib.licenses.asl20; } diff --git a/src/Network/GRPC/HighLevel/Generated.hs b/src/Network/GRPC/HighLevel/Generated.hs index 062b800..a635f51 100644 --- a/src/Network/GRPC/HighLevel/Generated.hs +++ b/src/Network/GRPC/HighLevel/Generated.hs @@ -80,7 +80,9 @@ data ServiceOptions = ServiceOptions , logger :: String -> IO () -- ^ 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 + -- ^ Maximum length (in bytes) that the service may receive in a single message. + , serverMaxMetadataSize :: Maybe Natural + -- ^ Maximum metadata size (in bytes) that the service may receive in a single request. } defaultServiceOptions :: ServiceOptions @@ -95,6 +97,7 @@ defaultServiceOptions = ServiceOptions , Network.GRPC.HighLevel.Generated.sslConfig = Nothing , Network.GRPC.HighLevel.Generated.logger = hPutStrLn stderr , Network.GRPC.HighLevel.Generated.serverMaxReceiveMessageLength = Nothing + , Network.GRPC.HighLevel.Generated.serverMaxMetadataSize = Nothing } withGRPCClient :: ClientConfig -> (Client -> IO a) -> IO a diff --git a/src/Network/GRPC/HighLevel/Server.hs b/src/Network/GRPC/HighLevel/Server.hs index 25a3d0e..480efb6 100644 --- a/src/Network/GRPC/HighLevel/Server.hs +++ b/src/Network/GRPC/HighLevel/Server.hs @@ -227,6 +227,9 @@ data ServerOptions = ServerOptions , optLogger :: String -> IO () -- ^ Logging function to use to log errors in handling calls. , optMaxReceiveMessageLength :: Maybe Natural + -- ^ Maximum length (in bytes) that the service may receive in a single message. + , optMaxMetadataSize :: Maybe Natural + -- ^ Maximum metadata size (in bytes) that the service may receive in a single request. } defaultOptions :: ServerOptions @@ -244,6 +247,7 @@ defaultOptions = ServerOptions , optSSLConfig = Nothing , optLogger = hPutStrLn stderr , optMaxReceiveMessageLength = Nothing + , optMaxMetadataSize = Nothing } serverLoop :: ServerOptions -> IO () diff --git a/src/Network/GRPC/HighLevel/Server/Unregistered.hs b/src/Network/GRPC/HighLevel/Server/Unregistered.hs index 77a1d7f..b3f2d29 100644 --- a/src/Network/GRPC/HighLevel/Server/Unregistered.hs +++ b/src/Network/GRPC/HighLevel/Server/Unregistered.hs @@ -124,5 +124,7 @@ serverLoop ServerOptions{..} = ] ++ foldMap (pure . MaxReceiveMessageLength) optMaxReceiveMessageLength + ++ + foldMap (pure . MaxMetadataSize) optMaxMetadataSize , sslConfig = optSSLConfig } diff --git a/tests/TestClient.hs b/tests/TestClient.hs index 9642757..f5ac879 100644 --- a/tests/TestClient.hs +++ b/tests/TestClient.hs @@ -36,7 +36,7 @@ import Test.Tasty.HUnit ((@?=), assertFailure, testCase) testNormalCall client = testCase "Normal call" $ do randoms <- fromList <$> replicateM 1000 (randomRIO (1, 1000)) let req = SimpleServiceRequest "NormalRequest" randoms - res <- simpleServiceNormalCall client + res <- simpleServicenormalCall client (ClientNormalRequest req 10 mempty) case res of ClientErrorResponse err -> assertFailure ("ClientErrorResponse: " <> show err) @@ -48,7 +48,7 @@ testNormalCall client = testCase "Normal call" $ testClientStreamingCall client = testCase "Client-streaming call" $ do iterationCount <- randomRIO (5, 50) v <- newEmptyMVar - res <- simpleServiceClientStreamingCall client . ClientWriterRequest 10 mempty $ \send -> + res <- simpleServiceclientStreamingCall client . ClientWriterRequest 10 mempty $ \send -> do (finalName, totalSum) <- fmap ((mconcat *** (sum . mconcat)) . unzip) . replicateM iterationCount $ @@ -86,7 +86,7 @@ testServerStreamingCall client = testCase "Server-streaming call" $ do response @?= "Test" num @?= expNum checkResults nums recv - res <- simpleServiceServerStreamingCall client $ + res <- simpleServiceserverStreamingCall client $ ClientReaderRequest (SimpleServiceRequest "Test" (fromList nums)) 10 mempty (\_ _ -> checkResults nums) case res of @@ -113,7 +113,7 @@ testBiDiStreamingCall client = testCase "Bidi-streaming call" $ iterations <- randomRIO (50, 500) - res <- simpleServiceBiDiStreamingCall client $ + res <- simpleServicebiDiStreamingCall client $ ClientBiDiRequest 10 mempty (\_ _ -> handleRequests iterations) case res of ClientErrorResponse err -> assertFailure ("ClientErrorResponse: " <> show err) @@ -132,4 +132,4 @@ main = do , testClientStreamingCall service , testServerStreamingCall service , testBiDiStreamingCall service ]) `finally` - (simpleServiceDone service (ClientNormalRequest SimpleServiceDone 10 mempty)) + (simpleServicedone service (ClientNormalRequest SimpleServiceDone 10 mempty)) diff --git a/tests/TestServer.hs b/tests/TestServer.hs index 1e83756..de49a41 100644 --- a/tests/TestServer.hs +++ b/tests/TestServer.hs @@ -64,11 +64,11 @@ main :: IO () main = do exitVar <- newEmptyMVar forkIO $ simpleServiceServer (SimpleService - { simpleServiceDone = handleDone exitVar - , simpleServiceNormalCall = handleNormalCall - , simpleServiceClientStreamingCall = handleClientStreamingCall - , simpleServiceServerStreamingCall = handleServerStreamingCall - , simpleServiceBiDiStreamingCall = handleBiDiStreamingCall }) + { simpleServicedone = handleDone exitVar + , simpleServicenormalCall = handleNormalCall + , simpleServiceclientStreamingCall = handleClientStreamingCall + , simpleServiceserverStreamingCall = handleServerStreamingCall + , simpleServicebiDiStreamingCall = handleBiDiStreamingCall }) defaultServiceOptions takeMVar exitVar