gRPC-haskell/tests/tmp/Simple.hs
Christian Lavoie 402e814a0b Fix tests.
2018-01-10 15:51:41 -05:00

282 lines
No EOL
13 KiB
Haskell

{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# 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 Simple 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.JSONPB as HsJSONPB
import Proto3.Suite.JSONPB ((.=), (.:))
import qualified Proto3.Wire as HsProtobuf
import Control.Applicative ((<*>), (<|>), (<$>))
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.Int as Hs (Int16, Int32, Int64)
import qualified Data.Word as Hs (Word16, Word32, Word64)
import qualified GHC.Generics as Hs
import qualified GHC.Enum 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)
import Network.GRPC.HighLevel.Server.Unregistered as HsGRPC
(serverLoop)
import Network.GRPC.LowLevel.Call as HsGRPC
data SimpleService request
response = SimpleService{simpleServiceNormalCall ::
request 'HsGRPC.Normal Simple.SimpleServiceRequest
Simple.SimpleServiceResponse
-> Hs.IO (response 'HsGRPC.Normal Simple.SimpleServiceResponse),
simpleServiceClientStreamingCall ::
request 'HsGRPC.ClientStreaming Simple.SimpleServiceRequest
Simple.SimpleServiceResponse
->
Hs.IO
(response 'HsGRPC.ClientStreaming Simple.SimpleServiceResponse),
simpleServiceServerStreamingCall ::
request 'HsGRPC.ServerStreaming Simple.SimpleServiceRequest
Simple.SimpleServiceResponse
->
Hs.IO
(response 'HsGRPC.ServerStreaming Simple.SimpleServiceResponse),
simpleServiceBiDiStreamingCall ::
request 'HsGRPC.BiDiStreaming Simple.SimpleServiceRequest
Simple.SimpleServiceResponse
->
Hs.IO
(response 'HsGRPC.BiDiStreaming Simple.SimpleServiceResponse),
simpleServiceDone ::
request 'HsGRPC.Normal Simple.SimpleServiceDone
Simple.SimpleServiceDone
-> Hs.IO (response 'HsGRPC.Normal Simple.SimpleServiceDone)}
deriving Hs.Generic
simpleServiceServer ::
SimpleService HsGRPC.ServerRequest HsGRPC.ServerResponse ->
HsGRPC.ServiceOptions -> Hs.IO ()
simpleServiceServer
SimpleService{simpleServiceNormalCall = simpleServiceNormalCall,
simpleServiceClientStreamingCall =
simpleServiceClientStreamingCall,
simpleServiceServerStreamingCall =
simpleServiceServerStreamingCall,
simpleServiceBiDiStreamingCall = simpleServiceBiDiStreamingCall,
simpleServiceDone = simpleServiceDone}
(ServiceOptions serverHost serverPort useCompression
userAgentPrefix userAgentSuffix initialMetadata sslConfig logger)
= (HsGRPC.serverLoop
HsGRPC.defaultOptions{HsGRPC.optNormalHandlers =
[(HsGRPC.UnaryHandler
(HsGRPC.MethodName "/simple.SimpleService/normalCall")
(HsGRPC.convertGeneratedServerHandler simpleServiceNormalCall)),
(HsGRPC.UnaryHandler
(HsGRPC.MethodName "/simple.SimpleService/done")
(HsGRPC.convertGeneratedServerHandler simpleServiceDone))],
HsGRPC.optClientStreamHandlers =
[(HsGRPC.ClientStreamHandler
(HsGRPC.MethodName "/simple.SimpleService/clientStreamingCall")
(HsGRPC.convertGeneratedServerReaderHandler
simpleServiceClientStreamingCall))],
HsGRPC.optServerStreamHandlers =
[(HsGRPC.ServerStreamHandler
(HsGRPC.MethodName "/simple.SimpleService/serverStreamingCall")
(HsGRPC.convertGeneratedServerWriterHandler
simpleServiceServerStreamingCall))],
HsGRPC.optBiDiStreamHandlers =
[(HsGRPC.BiDiStreamHandler
(HsGRPC.MethodName "/simple.SimpleService/biDiStreamingCall")
(HsGRPC.convertGeneratedServerRWHandler
simpleServiceBiDiStreamingCall))],
optServerHost = serverHost, optServerPort = serverPort,
optUseCompression = useCompression,
optUserAgentPrefix = userAgentPrefix,
optUserAgentSuffix = userAgentSuffix,
optInitialMetadata = initialMetadata, optSSLConfig = sslConfig,
optLogger = logger})
simpleServiceClient ::
HsGRPC.Client ->
Hs.IO (SimpleService HsGRPC.ClientRequest HsGRPC.ClientResult)
simpleServiceClient client
= (Hs.pure SimpleService) <*>
((Hs.pure (HsGRPC.clientRequest client)) <*>
(HsGRPC.clientRegisterMethod client
(HsGRPC.MethodName "/simple.SimpleService/normalCall")))
<*>
((Hs.pure (HsGRPC.clientRequest client)) <*>
(HsGRPC.clientRegisterMethod client
(HsGRPC.MethodName "/simple.SimpleService/clientStreamingCall")))
<*>
((Hs.pure (HsGRPC.clientRequest client)) <*>
(HsGRPC.clientRegisterMethod client
(HsGRPC.MethodName "/simple.SimpleService/serverStreamingCall")))
<*>
((Hs.pure (HsGRPC.clientRequest client)) <*>
(HsGRPC.clientRegisterMethod client
(HsGRPC.MethodName "/simple.SimpleService/biDiStreamingCall")))
<*>
((Hs.pure (HsGRPC.clientRequest client)) <*>
(HsGRPC.clientRegisterMethod client
(HsGRPC.MethodName "/simple.SimpleService/done")))
data SimpleServiceDone = SimpleServiceDone{}
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic)
instance HsProtobuf.Named SimpleServiceDone where
nameOf _ = (Hs.fromString "SimpleServiceDone")
instance HsProtobuf.Message SimpleServiceDone where
encodeMessage _ SimpleServiceDone{} = (Hs.mconcat [])
decodeMessage _ = (Hs.pure SimpleServiceDone)
dotProto _ = []
instance HsJSONPB.ToJSONPB SimpleServiceDone where
toJSONPB (SimpleServiceDone) = (HsJSONPB.object [])
toEncodingPB (SimpleServiceDone) = (HsJSONPB.pairs [])
instance HsJSONPB.FromJSONPB SimpleServiceDone where
parseJSONPB
= (HsJSONPB.withObject "SimpleServiceDone"
(\ obj -> (Hs.pure SimpleServiceDone)))
instance HsJSONPB.ToJSON SimpleServiceDone where
toJSON = HsJSONPB.toAesonValue
toEncoding = HsJSONPB.toAesonEncoding
instance HsJSONPB.FromJSON SimpleServiceDone where
parseJSON = HsJSONPB.parseJSONPB
instance HsJSONPB.ToSchema SimpleServiceDone where
declareNamedSchema = HsJSONPB.genericDeclareNamedSchemaJSONPB
data SimpleServiceRequest = SimpleServiceRequest{simpleServiceRequestRequest
:: Hs.Text,
simpleServiceRequestNum ::
Hs.Vector (HsProtobuf.Fixed Hs.Word32)}
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic)
instance HsProtobuf.Named SimpleServiceRequest where
nameOf _ = (Hs.fromString "SimpleServiceRequest")
instance HsProtobuf.Message SimpleServiceRequest where
encodeMessage _
SimpleServiceRequest{simpleServiceRequestRequest =
simpleServiceRequestRequest,
simpleServiceRequestNum = simpleServiceRequestNum}
= (Hs.mconcat
[(HsProtobuf.encodeMessageField (HsProtobuf.FieldNumber 1)
simpleServiceRequestRequest),
(HsProtobuf.encodeMessageField (HsProtobuf.FieldNumber 2)
(HsProtobuf.PackedVec simpleServiceRequestNum))])
decodeMessage _
= (Hs.pure SimpleServiceRequest) <*>
(HsProtobuf.at HsProtobuf.decodeMessageField
(HsProtobuf.FieldNumber 1))
<*>
((Hs.pure HsProtobuf.packedvec) <*>
(HsProtobuf.at HsProtobuf.decodeMessageField
(HsProtobuf.FieldNumber 2)))
dotProto _
= [(HsProtobuf.DotProtoField (HsProtobuf.FieldNumber 1)
(HsProtobuf.Prim HsProtobuf.String)
(HsProtobuf.Single "request")
[]
Hs.Nothing),
(HsProtobuf.DotProtoField (HsProtobuf.FieldNumber 2)
(HsProtobuf.Repeated HsProtobuf.Fixed32)
(HsProtobuf.Single "num")
[]
Hs.Nothing)]
instance HsJSONPB.ToJSONPB SimpleServiceRequest where
toJSONPB (SimpleServiceRequest f1 f2)
= (HsJSONPB.object ["request" .= f1, "num" .= f2])
toEncodingPB (SimpleServiceRequest f1 f2)
= (HsJSONPB.pairs ["request" .= f1, "num" .= f2])
instance HsJSONPB.FromJSONPB SimpleServiceRequest where
parseJSONPB
= (HsJSONPB.withObject "SimpleServiceRequest"
(\ obj ->
(Hs.pure SimpleServiceRequest) <*> obj .: "request" <*>
obj .: "num"))
instance HsJSONPB.ToJSON SimpleServiceRequest where
toJSON = HsJSONPB.toAesonValue
toEncoding = HsJSONPB.toAesonEncoding
instance HsJSONPB.FromJSON SimpleServiceRequest where
parseJSON = HsJSONPB.parseJSONPB
instance HsJSONPB.ToSchema SimpleServiceRequest where
declareNamedSchema = HsJSONPB.genericDeclareNamedSchemaJSONPB
data SimpleServiceResponse = SimpleServiceResponse{simpleServiceResponseResponse
:: Hs.Text,
simpleServiceResponseNum ::
HsProtobuf.Fixed Hs.Word32}
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic)
instance HsProtobuf.Named SimpleServiceResponse where
nameOf _ = (Hs.fromString "SimpleServiceResponse")
instance HsProtobuf.Message SimpleServiceResponse where
encodeMessage _
SimpleServiceResponse{simpleServiceResponseResponse =
simpleServiceResponseResponse,
simpleServiceResponseNum = simpleServiceResponseNum}
= (Hs.mconcat
[(HsProtobuf.encodeMessageField (HsProtobuf.FieldNumber 1)
simpleServiceResponseResponse),
(HsProtobuf.encodeMessageField (HsProtobuf.FieldNumber 2)
simpleServiceResponseNum)])
decodeMessage _
= (Hs.pure SimpleServiceResponse) <*>
(HsProtobuf.at HsProtobuf.decodeMessageField
(HsProtobuf.FieldNumber 1))
<*>
(HsProtobuf.at HsProtobuf.decodeMessageField
(HsProtobuf.FieldNumber 2))
dotProto _
= [(HsProtobuf.DotProtoField (HsProtobuf.FieldNumber 1)
(HsProtobuf.Prim HsProtobuf.String)
(HsProtobuf.Single "response")
[]
Hs.Nothing),
(HsProtobuf.DotProtoField (HsProtobuf.FieldNumber 2)
(HsProtobuf.Prim HsProtobuf.Fixed32)
(HsProtobuf.Single "num")
[]
Hs.Nothing)]
instance HsJSONPB.ToJSONPB SimpleServiceResponse where
toJSONPB (SimpleServiceResponse f1 f2)
= (HsJSONPB.object ["response" .= f1, "num" .= f2])
toEncodingPB (SimpleServiceResponse f1 f2)
= (HsJSONPB.pairs ["response" .= f1, "num" .= f2])
instance HsJSONPB.FromJSONPB SimpleServiceResponse where
parseJSONPB
= (HsJSONPB.withObject "SimpleServiceResponse"
(\ obj ->
(Hs.pure SimpleServiceResponse) <*> obj .: "response" <*>
obj .: "num"))
instance HsJSONPB.ToJSON SimpleServiceResponse where
toJSON = HsJSONPB.toAesonValue
toEncoding = HsJSONPB.toAesonEncoding
instance HsJSONPB.FromJSON SimpleServiceResponse where
parseJSON = HsJSONPB.parseJSONPB
instance HsJSONPB.ToSchema SimpleServiceResponse where
declareNamedSchema = HsJSONPB.genericDeclareNamedSchemaJSONPB