mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-11-23 03:29:42 +01:00
Fix examples (#115)
Fixes https://github.com/awakesecurity/gRPC-haskell/issues/112
This commit is contained in:
parent
0cb7999e9e
commit
2af32db3a9
5 changed files with 56 additions and 41 deletions
42
examples/echo/echo-hs/Echo.hs
generated
42
examples/echo/echo-hs/Echo.hs
generated
|
@ -1,32 +1,40 @@
|
|||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE GADTs #-}
|
||||
{-# LANGUAGE TypeApplications #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
|
||||
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
|
||||
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
|
||||
|
||||
-- | Generated by Haskell protocol buffer compiler. DO NOT EDIT!
|
||||
|
||||
module Echo where
|
||||
import qualified Prelude as Hs
|
||||
import qualified Proto3.Suite.DotProto as HsProtobuf
|
||||
import qualified Proto3.Suite.Types as HsProtobuf
|
||||
import qualified Proto3.Suite.Class as HsProtobuf
|
||||
import qualified Proto3.Suite.DotProto as HsProtobuf
|
||||
import qualified Proto3.Suite.JSONPB as HsJSONPB
|
||||
import Proto3.Suite.JSONPB ((.=), (.:))
|
||||
import qualified Proto3.Suite.Types as HsProtobuf
|
||||
import qualified Proto3.Wire as HsProtobuf
|
||||
import Control.Applicative ((<*>), (<|>), (<$>))
|
||||
import qualified Control.Applicative as Hs
|
||||
import Control.Applicative ((<*>), (<|>), (<$>))
|
||||
import qualified Control.DeepSeq as Hs
|
||||
import qualified Control.Monad as Hs
|
||||
import qualified Data.Text.Lazy as Hs (Text)
|
||||
import qualified Data.ByteString as Hs
|
||||
import qualified Data.String as Hs (fromString)
|
||||
import qualified Data.Vector as Hs (Vector)
|
||||
import qualified Data.Coerce as Hs
|
||||
import qualified Data.Int as Hs (Int16, Int32, Int64)
|
||||
import qualified Data.Word as Hs (Word16, Word32, Word64)
|
||||
import qualified Data.List.NonEmpty as Hs (NonEmpty(..))
|
||||
import qualified Data.Map as Hs (Map, mapKeysMonotonic)
|
||||
import qualified Data.Proxy as Proxy
|
||||
import qualified GHC.Generics as Hs
|
||||
import qualified Data.String as Hs (fromString)
|
||||
import qualified Data.Text.Lazy as Hs (Text)
|
||||
import qualified Data.Vector as Hs (Vector)
|
||||
import qualified Data.Word as Hs (Word16, Word32, Word64)
|
||||
import qualified GHC.Enum as Hs
|
||||
import qualified GHC.Generics as Hs
|
||||
import qualified Unsafe.Coerce as Hs
|
||||
import Network.GRPC.HighLevel.Generated as HsGRPC
|
||||
import Network.GRPC.HighLevel.Client as HsGRPC
|
||||
import Network.GRPC.HighLevel.Server as HsGRPC hiding (serverLoop)
|
||||
|
@ -43,7 +51,8 @@ echoServer ::
|
|||
HsGRPC.ServiceOptions -> Hs.IO ()
|
||||
echoServer Echo{echoDoEcho = echoDoEcho}
|
||||
(ServiceOptions serverHost serverPort useCompression
|
||||
userAgentPrefix userAgentSuffix initialMetadata sslConfig logger)
|
||||
userAgentPrefix userAgentSuffix initialMetadata sslConfig logger
|
||||
serverMaxReceiveMessageLength)
|
||||
= (HsGRPC.serverLoop
|
||||
HsGRPC.defaultOptions{HsGRPC.optNormalHandlers =
|
||||
[(HsGRPC.UnaryHandler (HsGRPC.MethodName "/echo.Echo/DoEcho")
|
||||
|
@ -55,7 +64,8 @@ echoServer Echo{echoDoEcho = echoDoEcho}
|
|||
optUserAgentPrefix = userAgentPrefix,
|
||||
optUserAgentSuffix = userAgentSuffix,
|
||||
optInitialMetadata = initialMetadata, optSSLConfig = sslConfig,
|
||||
optLogger = logger})
|
||||
optLogger = logger,
|
||||
optMaxReceiveMessageLength = serverMaxReceiveMessageLength})
|
||||
|
||||
echoClient ::
|
||||
HsGRPC.Client ->
|
||||
|
@ -66,12 +76,14 @@ echoClient client
|
|||
(HsGRPC.clientRegisterMethod client
|
||||
(HsGRPC.MethodName "/echo.Echo/DoEcho")))
|
||||
|
||||
data EchoRequest = EchoRequest{echoRequestMessage :: Hs.Text}
|
||||
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic)
|
||||
newtype EchoRequest = EchoRequest{echoRequestMessage :: Hs.Text}
|
||||
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic, Hs.NFData)
|
||||
|
||||
instance HsProtobuf.Named EchoRequest where
|
||||
nameOf _ = (Hs.fromString "EchoRequest")
|
||||
|
||||
instance HsProtobuf.HasDefault EchoRequest
|
||||
|
||||
instance HsProtobuf.Message EchoRequest where
|
||||
encodeMessage _
|
||||
EchoRequest{echoRequestMessage = echoRequestMessage}
|
||||
|
@ -121,12 +133,14 @@ instance HsJSONPB.ToSchema EchoRequest where
|
|||
HsJSONPB.insOrdFromList
|
||||
[("message", echoRequestMessage)]}})
|
||||
|
||||
data EchoResponse = EchoResponse{echoResponseMessage :: Hs.Text}
|
||||
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic)
|
||||
newtype EchoResponse = EchoResponse{echoResponseMessage :: Hs.Text}
|
||||
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic, Hs.NFData)
|
||||
|
||||
instance HsProtobuf.Named EchoResponse where
|
||||
nameOf _ = (Hs.fromString "EchoResponse")
|
||||
|
||||
instance HsProtobuf.HasDefault EchoResponse
|
||||
|
||||
instance HsProtobuf.Message EchoResponse where
|
||||
encodeMessage _
|
||||
EchoResponse{echoResponseMessage = echoResponseMessage}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
import Control.Monad
|
||||
import Data.Function (fix)
|
||||
import Data.Monoid
|
||||
import qualified Data.Text as T
|
||||
import Data.Word
|
||||
import GHC.Generics (Generic)
|
||||
|
|
6
examples/tutorial/Arithmetic.hs
generated
6
examples/tutorial/Arithmetic.hs
generated
|
@ -62,7 +62,8 @@ arithmeticServer
|
|||
Arithmetic{arithmeticAdd = arithmeticAdd,
|
||||
arithmeticRunningSum = arithmeticRunningSum}
|
||||
(ServiceOptions serverHost serverPort useCompression
|
||||
userAgentPrefix userAgentSuffix initialMetadata sslConfig logger)
|
||||
userAgentPrefix userAgentSuffix initialMetadata sslConfig logger
|
||||
serverMaxReceiveMessageLength)
|
||||
= (HsGRPC.serverLoop
|
||||
HsGRPC.defaultOptions{HsGRPC.optNormalHandlers =
|
||||
[(HsGRPC.UnaryHandler
|
||||
|
@ -79,7 +80,8 @@ arithmeticServer
|
|||
optUserAgentPrefix = userAgentPrefix,
|
||||
optUserAgentSuffix = userAgentSuffix,
|
||||
optInitialMetadata = initialMetadata, optSSLConfig = sslConfig,
|
||||
optLogger = logger})
|
||||
optLogger = logger,
|
||||
optMaxReceiveMessageLength = serverMaxReceiveMessageLength})
|
||||
|
||||
arithmeticClient ::
|
||||
HsGRPC.Client ->
|
||||
|
|
|
@ -97,6 +97,7 @@ executable echo-server
|
|||
, async
|
||||
, bytestring == 0.10.*
|
||||
, containers >=0.5 && <0.7
|
||||
, deepseq
|
||||
, grpc-haskell
|
||||
, grpc-haskell-core
|
||||
, optparse-generic
|
||||
|
@ -169,6 +170,7 @@ executable echo-client
|
|||
, async
|
||||
, bytestring == 0.10.*
|
||||
, containers >=0.5 && <0.7
|
||||
, deepseq
|
||||
, grpc-haskell
|
||||
, grpc-haskell-core
|
||||
, optparse-generic
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
# If you would like to test and build changes quickly using `cabal`, run:
|
||||
#
|
||||
# $ # Consider adding the following command to your `~/.profile`
|
||||
# $ NIX_PATH="${NIX_PATH}:ssh-config-file=${HOME}/.ssh/config:ssh-auth-sock=${SSH_AUTH_SOCK}"
|
||||
# $ nix-shell -A grpc-haskell.env release.nix
|
||||
# [nix-shell]$ cabal configure --enable-tests && cabal build && cabal test
|
||||
# $ nix-shell
|
||||
# [nix-shell]$ cabal configure --enable-tests && cabal test
|
||||
#
|
||||
# This will open up a Nix shell where all of your Haskell tools will work like
|
||||
# normal, except that all dependencies (including C libraries) are managed by
|
||||
|
|
Loading…
Reference in a new issue