-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nicer handling for gRPC status codes. #6
Comments
Hello, I was trying to use mu-haskell for grpc calls and get some errors out of it. But on any grpc errors, I just get "not enough bytes". My guess is that it is coming from here, but I am not sure: http2-grpc-haskell/http2-client-grpc/src/Network/GRPC/Client.hs Lines 140 to 145 in fcc9e6f
Here is some code which reproduces the error:cabal.project:
Main.hs:{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wno-partial-type-signatures #-}
module Main where
import Control.Concurrent
import Control.Concurrent.Async
import Control.Monad (forever)
import Control.Monad.Except
import Data.Text (Text)
import GHC.TypeLits
import Mu.Adapter.ProtoBuf
import Mu.GRpc.Client.Optics
import Mu.GRpc.Client.TyApps
import Mu.GRpc.Server
import Mu.Rpc
import Mu.Schema
import Mu.Server
main :: IO ()
main =
concurrently_ serve (forever $ query >> threadDelay 1000000)
type MySchema = '[ 'DRecord "Foo" '[ 'FieldDef "foo" ('TPrimitive Text)]]
type MyService =
'Package
('Just "pkg")
'[ 'Service
"MyService"
'[ 'Method
"identityFoo"
'[ 'ArgSingle ('Nothing :: Maybe Symbol) ('SchemaRef MySchema "Foo")]
('RetSingle ('SchemaRef MySchema "Foo"))
]
]
type instance
AnnotatedSchema ProtoBufAnnotation MySchema =
'[ 'AnnField "Foo" "foo" ('ProtoBufId 1 '[])]
type Foo = Term MySchema (MySchema :/: "Foo")
identityFoo :: MonadServer m => Foo -> m Foo
identityFoo _ = throwError $ ServerError NotFound "nothing to see here"
-- identityFoo = pure
service :: MonadServer m => SingleServerT i MyService m _
service = singleService (method @"identityFoo" identityFoo)
serve :: IO ()
serve = runGRpcApp msgProtoBuf 8080 service
mkClient :: IO GrpcClient
mkClient = assertRight =<< setupGrpcClient' (grpcClientConfigSimple "127.0.0.1" 8080 False)
assertRight :: Show a => Either a b -> IO b
assertRight = either (error . show) pure
query :: IO ()
query = do
c <- mkClient
r :: GRpcReply Foo <- gRpcCall @'MsgProtoBuf @MyService @"MyService" @"identityFoo" c bar
case r of
GRpcErrorString str -> putStrLn $ "GRpcError: " <> str
GRpcOk x -> putStrLn $ "Ok: " <> show x
_ -> putStrLn "Unexpected!"
bar :: Foo
bar = record1 "bar" |
I looked more deeply into this and found that this happens because this part of code doesn't look at This raises a design of question about the http2-grpc-haskell/http2-client-grpc/src/Network/GRPC/Client.hs Lines 104 to 114 in fcc9e6f
The |
Actually changing |
This is the new home for discussions around lucasdicioccio/http2-client-grpc#16 .
Definitely related to #5 .
The text was updated successfully, but these errors were encountered: