mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-12-24 02:39:45 +01:00
Update to latest proto3-suite
, remove compile-proto-file
exe (#23)
* Squash merge from branch `joel-fix-build-issues-and-broken-tests` * Update `proto3-wire` and `proto3-suite` refs in `stack.yaml` * Update `proto3-wire` and `proto3-suite` refs via `cabal2nix` for `nix` builds * Remove `compile-proto-file` from the repo, as it is now available via `proto3-suite` * Update `proto3-suite` ref in `stack.yaml` * Update `proto3-suite` ref via `cabal2nix` for `nix` builds * Update `proto3-suite` and `proto3-wire` gitrevs * Regenerate Echo and Arithmetic example modules from their respective .protos * Fix typo
This commit is contained in:
parent
7d2e797ad5
commit
fe55845d3f
11 changed files with 33 additions and 92 deletions
18
README.md
18
README.md
|
@ -9,29 +9,11 @@ Installation
|
|||
|
||||
**The current version of this library requires gRPC version 1.2.0. Newer versions may work but have not been tested.**
|
||||
|
||||
Run the following command from the root of this repository to install the
|
||||
`compile-proto-file` executable:
|
||||
|
||||
```bash
|
||||
$ nix-env -iA grpc-haskell -f release.nix
|
||||
```
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
There is a tutorial [here](examples/tutorial/TUTORIAL.md)
|
||||
|
||||
```bash
|
||||
$ compile-proto-file --help
|
||||
Dumps a compiled .proto file to stdout
|
||||
|
||||
Usage: compile-proto-file --proto FILEPATH
|
||||
|
||||
Available options:
|
||||
-h,--help Show this help text
|
||||
--proto FILEPATH Path to input .proto file
|
||||
```
|
||||
|
||||
Building and testing
|
||||
--------------------
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import qualified Proto3.Suite.Types as HsProtobuf
|
|||
import qualified Proto3.Suite.Class as HsProtobuf
|
||||
import qualified Proto3.Wire as HsProtobuf
|
||||
import Control.Applicative ((<*>), (<|>))
|
||||
import qualified Data.Text as Hs (Text)
|
||||
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)
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
import Control.Monad
|
||||
import Data.ByteString (ByteString)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import qualified Data.Text.Lazy as TL
|
||||
import Echo
|
||||
import GHC.Generics (Generic)
|
||||
import Network.GRPC.HighLevel.Client
|
||||
import Network.GRPC.HighLevel.Generated
|
||||
|
@ -17,12 +19,10 @@ import Network.GRPC.LowLevel
|
|||
import Options.Generic
|
||||
import Prelude hiding (FilePath)
|
||||
|
||||
import Echo
|
||||
|
||||
data Args = Args
|
||||
{ bind :: Maybe ByteString <?> "grpc endpoint hostname (default \"localhost\")"
|
||||
, port :: Maybe Int <?> "grpc endpoint port (default 50051)"
|
||||
, payload :: Maybe Text <?> "string to echo (default \"hullo!\")"
|
||||
, payload :: Maybe TL.Text <?> "string to echo (default \"hullo!\")"
|
||||
} deriving (Generic, Show)
|
||||
instance ParseRecord Args
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import qualified Proto3.Suite.Types as HsProtobuf
|
|||
import qualified Proto3.Suite.Class as HsProtobuf
|
||||
import qualified Proto3.Wire as HsProtobuf
|
||||
import Control.Applicative ((<*>), (<|>))
|
||||
import qualified Data.Text as Hs (Text)
|
||||
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)
|
||||
|
|
|
@ -29,7 +29,7 @@ This library exposes quite a few modules, but you won't need to worry about most
|
|||
|
||||
### Getting started
|
||||
|
||||
To start out, we need to generate code for our protocol buffers and RPCs. The `compile-proto-file` command is provided as part of `grpc-haskell`. You can either use `stack install` to install the command globally, or use `stack exec` within the `grpc-haskell` directory.
|
||||
To start out, we need to generate code for our protocol buffers and RPCs. The `compile-proto-file` command is provided as part of `proto3-suite`. You can either use `stack install` in the `proto3-suite` repository to install the command globally, or use `stack exec` from within the `grpc-haskell` directory.
|
||||
|
||||
```
|
||||
$ stack exec -- compile-proto-file --proto examples/echo/echo.proto > examples/echo/echo-hs/Echo.hs
|
||||
|
|
|
@ -93,24 +93,6 @@ library
|
|||
CPP-Options: -DDEBUG
|
||||
CC-Options: -DGRPC_HASKELL_DEBUG -std=c99
|
||||
|
||||
executable compile-proto-file
|
||||
build-depends: base >=4.8 && <5.0
|
||||
, async
|
||||
, bytestring == 0.10.*
|
||||
, containers ==0.5.*
|
||||
, grpc-haskell
|
||||
, optparse-generic
|
||||
, proto3-suite
|
||||
, proto3-wire
|
||||
, system-filepath
|
||||
, text
|
||||
, transformers
|
||||
, turtle
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall -g -threaded -rtsopts -with-rtsopts=-N -O2
|
||||
hs-source-dirs: tools/compile-proto-file
|
||||
main-is: Main.hs
|
||||
|
||||
executable hellos-server
|
||||
if flag(with-examples)
|
||||
build-depends:
|
||||
|
|
|
@ -1,24 +1,31 @@
|
|||
{ mkDerivation, base, bytestring, cereal, containers, deepseq
|
||||
, fetchgit, filepath, haskell-src, mtl, parsec, parsers, pipes
|
||||
, pretty, proto3-wire, QuickCheck, safe, semigroups, stdenv, tasty
|
||||
, tasty-hunit, tasty-quickcheck, text, transformers, turtle, vector
|
||||
, fetchgit, filepath, haskell-src, mtl, optparse-generic, parsec
|
||||
, parsers, pretty, pretty-show, proto3-wire, QuickCheck, safe
|
||||
, semigroups, stdenv, system-filepath, tasty, tasty-hunit
|
||||
, tasty-quickcheck, text, transformers, turtle, vector
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "proto3-suite";
|
||||
version = "0.1.0.0";
|
||||
src = fetchgit {
|
||||
url = "https://github.com/awakenetworks/proto3-suite.git";
|
||||
sha256 = "1w5qwwlivrxkd6943rxsw3znk9jjpf7ad11gm0zl4lzq6k3kdinp";
|
||||
rev = "46f40d38c4db8a6320bab010ae30e75c83fab6ee";
|
||||
url = "https://github.com/awakenetworks/proto3-suite";
|
||||
sha256 = "1wqs209sfwjiwvpv8zz49jk9l6pivqz06r0m1rfxvsdmxh80kp7d";
|
||||
rev = "48d452d42e8d73acfa88a56a54586d17bae711db";
|
||||
};
|
||||
isLibrary = true;
|
||||
isExecutable = true;
|
||||
libraryHaskellDepends = [
|
||||
base bytestring cereal containers deepseq filepath haskell-src mtl
|
||||
parsec parsers pipes pretty proto3-wire QuickCheck safe semigroups
|
||||
text transformers vector
|
||||
parsec parsers pretty pretty-show proto3-wire QuickCheck safe
|
||||
semigroups text transformers vector
|
||||
];
|
||||
executableHaskellDepends = [
|
||||
base optparse-generic system-filepath turtle
|
||||
];
|
||||
testHaskellDepends = [
|
||||
base bytestring cereal proto3-wire QuickCheck semigroups tasty
|
||||
tasty-hunit tasty-quickcheck text transformers turtle
|
||||
base bytestring cereal pretty-show proto3-wire QuickCheck
|
||||
semigroups 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;
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
{ mkDerivation, base, bytestring, cereal, containers, deepseq
|
||||
, fetchgit, QuickCheck, safe, stdenv, tasty, tasty-hunit
|
||||
, tasty-quickcheck, text
|
||||
, doctest, fetchgit, hashable, QuickCheck, safe, stdenv, tasty
|
||||
, tasty-hunit, tasty-quickcheck, text, unordered-containers
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "proto3-wire";
|
||||
version = "1.0.0";
|
||||
src = fetchgit {
|
||||
url = "https://github.com/awakenetworks/proto3-wire.git";
|
||||
sha256 = "10z1sirmiz29r2nx5dza1y1p3kp83wsq80pz4msxqmaykpyh5iaa";
|
||||
rev = "62b50ea460847dde5bc8e63d2f93360d9bfcae9d";
|
||||
url = "https://github.com/awakenetworks/proto3-wire";
|
||||
sha256 = "1979pccp8c8wvl69r203mji51c8s59mccng6zrw3kf2s1wz5xxqg";
|
||||
rev = "8178cc717eb1c438272a7f451862590a8b2d41ff";
|
||||
};
|
||||
libraryHaskellDepends = [
|
||||
base bytestring cereal containers deepseq QuickCheck safe text
|
||||
base bytestring cereal containers deepseq hashable QuickCheck safe
|
||||
text unordered-containers
|
||||
];
|
||||
testHaskellDepends = [
|
||||
base bytestring cereal QuickCheck tasty tasty-hunit
|
||||
base bytestring cereal doctest QuickCheck tasty tasty-hunit
|
||||
tasty-quickcheck text
|
||||
];
|
||||
description = "A low-level implementation of the Protocol Buffers (version 3) wire format";
|
||||
|
|
|
@ -257,11 +257,6 @@ let
|
|||
--prefix PATH : ${ghc}/bin
|
||||
'';
|
||||
|
||||
postInstall = pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
|
||||
wrapProgram $out/bin/compile-proto-file \
|
||||
--prefix DYLD_LIBRARY_PATH : ${grpc}/lib
|
||||
'';
|
||||
|
||||
shellHook = (oldDerivation.shellHook or "") + ''
|
||||
export DYLD_LIBRARY_PATH=${grpc}/lib''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH
|
||||
# This lets us use our custom ghc and python environments in the shell.
|
||||
|
|
|
@ -9,11 +9,11 @@ packages:
|
|||
- '.'
|
||||
- location:
|
||||
git: git@github.com:awakenetworks/proto3-suite.git
|
||||
commit: 8db2ceb8c48a3f8dc2cbdc492d1e8cbaf8b62a15
|
||||
commit: 10f592cdd5349e33d4924b066d4f6e27ada5e5c5
|
||||
extra-dep: true
|
||||
- location:
|
||||
git: git@github.com:awakenetworks/proto3-wire.git
|
||||
commit: 1b88bf24aad15db1f59a00d201d609fa308157f7
|
||||
commit: 4cf2f349cbf27ef36af28ae51e2712d6cf5f7723
|
||||
extra-dep: true
|
||||
# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
|
||||
extra-deps: [managed-1.0.5]
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
|
||||
import Data.Monoid ((<>))
|
||||
import Filesystem.Path.CurrentOS (encodeString)
|
||||
import Options.Generic
|
||||
import Proto3.Suite.DotProto.Generate
|
||||
import Prelude hiding (FilePath)
|
||||
import Turtle (FilePath)
|
||||
|
||||
data Args = Args
|
||||
{ proto :: FilePath <?> "Path to input .proto file"
|
||||
} deriving (Generic, Show)
|
||||
instance ParseRecord Args
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
protoPath <- encodeString . unHelpful . proto <$> getRecord "Dumps a compiled .proto file to stdout"
|
||||
readDotProtoWithContext protoPath >>= \case
|
||||
Left err -> fail (show err)
|
||||
Right (dp, ctx) -> case renderHsModuleForDotProto dp ctx of
|
||||
Left err -> fail ("Error compiling " <> protoPath <> ": " <> show err)
|
||||
Right src -> putStrLn src
|
Loading…
Reference in a new issue