-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support the
endpoint-load-metrics-bin
header
We are still a long way from supporting ORCA (#72) but at least clients will be able to read the ORCA load report sent by the server. This restores compatibility with the interop test suite.
- Loading branch information
Showing
9 changed files
with
163 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Network.GRPC.Spec.OrcaLoadReport ( | ||
OrcaLoadReport | ||
) where | ||
|
||
import Proto.OrcaLoadReport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
-- | Protobuf utilities | ||
-- | ||
-- Intended for qualified import. | ||
-- | ||
-- > import Network.GRPC.Util.Protobuf qualified as Protobuf | ||
module Network.GRPC.Util.Protobuf ( | ||
-- * Serialization | ||
parseStrict | ||
, parseLazy | ||
, buildStrict | ||
, buildLazy | ||
) where | ||
|
||
import Data.Binary.Builder qualified as Builder | ||
import Data.ByteString qualified as Strict (ByteString) | ||
import Data.ByteString.Lazy qualified as BS.Lazy | ||
import Data.ByteString.Lazy qualified as Lazy (ByteString) | ||
import Data.ProtoLens (Message) | ||
import Data.ProtoLens qualified as Protobuf | ||
import Data.ProtoLens.Encoding.Parser (Parser) | ||
import Data.ProtoLens.Encoding.Parser qualified as Protobuf | ||
import Data.Proxy | ||
import Data.Text qualified as Text | ||
|
||
{------------------------------------------------------------------------------- | ||
Serialization | ||
-------------------------------------------------------------------------------} | ||
|
||
parseStrict :: Message msg => Strict.ByteString -> Either String msg | ||
parseStrict = Protobuf.runParser parseMessage | ||
|
||
parseLazy :: Message msg => Lazy.ByteString -> Either String msg | ||
parseLazy = parseStrict . BS.Lazy.toStrict | ||
|
||
buildStrict :: Message msg => msg -> Strict.ByteString | ||
buildStrict = BS.Lazy.toStrict . buildLazy | ||
|
||
buildLazy :: Message msg => msg -> Lazy.ByteString | ||
buildLazy = Builder.toLazyByteString . Protobuf.buildMessage | ||
|
||
{------------------------------------------------------------------------------- | ||
Internal auxilairy | ||
-------------------------------------------------------------------------------} | ||
|
||
parseMessage :: forall msg. Protobuf.Message msg => Parser msg | ||
parseMessage = do | ||
msg <- Protobuf.parseMessage | ||
atEnd <- Protobuf.atEnd | ||
if atEnd then | ||
return msg | ||
else | ||
fail $ concat [ | ||
Text.unpack $ Protobuf.messageName $ Proxy @msg | ||
, ": unconsumed bytes" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.