Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
[#1] Add first protocol buffers message and print its serialization t…
Browse files Browse the repository at this point in the history
…o terminal (#3)

* Add protobuf file with very simple message issue #1

* Edit proto-route.cabal and add Setup.hs files issue #1

* Encounter errors with Haskell file generation issue #1

* Attempt to fix .hs file generation errors with stack issue #1

* Resolve error in generating haskell files issue #1

* Create value of generated message and print to console issue #1

* Print serialized representation issue #1

* Encounter errors in ghci representation issue #1

* Resolve errors in ghci representation issue #1

* Refactor files to improve further modularity issue #1

* Modify ChangeLog.md to include links issue #1

* Re-modify ChangeLog.md to include links issue #1
  • Loading branch information
TejasSC authored and chshersh committed Aug 13, 2018
1 parent 11b205a commit 0618511
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 31 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ The change log is available [on GitHub][2].

[1]: https://pvp.haskell.org
[2]: https://github.com/holmusk/proto-route/releases

6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,3 @@

[![Hackage](https://img.shields.io/hackage/v/proto-route.svg)](https://hackage.haskell.org/package/proto-route)
[![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/holmusk/proto-route/blob/master/LICENSE)




Remote testing tool for protobuf endpoints

3 changes: 3 additions & 0 deletions Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Data.ProtoLens.Setup (defaultMainGeneratingProtos)

main = defaultMainGeneratingProtos "proto"
5 changes: 2 additions & 3 deletions app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Main where

import ProtoRoute (someFunc)
import qualified ProtoRoute

main :: IO ()
main = someFunc

main = ProtoRoute.main
37 changes: 27 additions & 10 deletions proto-route.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,50 @@ author: Holmusk
maintainer: tech@holmusk.com
copyright: 2018 Holmusk
category: Protobuf, Network
build-type: Simple
build-type: Custom
extra-doc-files: README.md
, CHANGELOG.md
cabal-version: 1.24
tested-with: GHC == 8.4.3
extra-source-files: proto/protobuf1.proto

source-repository head
type: git
location: https://github.com/holmusk/proto-route.git

custom-setup
setup-depends:
Cabal
, base
, proto-lens-protoc

library
hs-source-dirs: src
exposed-modules: ProtoRoute
Prelude
exposed-modules: ProtoExports
ProtoRoute
Proto.Protobuf1
Proto.Protobuf1_Fields
ghc-options: -Wall
build-depends: base-noprelude
, universum
build-depends: base >=4.7 && <5
, directory
, ghcid
, protobuf
, proto-lens
, proto-lens-protoc
, text
default-language: Haskell2010


executable proto-route
hs-source-dirs: app
main-is: Main.hs
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
build-depends: base-noprelude
build-depends: base
, directory
, ghcid
, protobuf
, proto-lens
, proto-lens-protoc
, proto-route
, universum
, text
default-language: Haskell2010


5 changes: 5 additions & 0 deletions proto/protobuf1.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
syntax = "proto2";

message SearchRequest {
required string query = 1;
}
8 changes: 0 additions & 8 deletions src/Prelude.hs

This file was deleted.

7 changes: 7 additions & 0 deletions src/ProtoExports.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module ProtoExports
( module Proto.Protobuf1
, module Proto.Protobuf1_Fields
) where

import Proto.Protobuf1
import Proto.Protobuf1_Fields
21 changes: 18 additions & 3 deletions src/ProtoRoute.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
module ProtoRoute
( someFunc
( main
) where

someFunc :: IO ()
someFunc = putStrLn ("someFunc" :: String)
import Language.Haskell.Ghcid (execStream, startGhci, stopGhci)
import System.Directory (getCurrentDirectory)

main :: IO ()
main = do
let f = \_ s -> putStrLn s
curDir <- getCurrentDirectory
(g, _) <- startGhci "ghci" (Just curDir) f
let execStatement s = execStream g s f
execStatement "import Data.Text"
execStatement "import Data.ProtoLens.Encoding"
execStatement ":load src/ProtoExports"
execStatement "let sr = SearchRequest {_SearchRequest'query = pack \"test\"\
\, _SearchRequest'_unknownFields = ([])}"
-- Value of generated msg, and its serialized representation
execStatement "sr"
execStatement "encodeMessage sr"
stopGhci g
4 changes: 4 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resolver: lts-12.6

extra-deps:
- base-noprelude-4.10.1.0
2 changes: 2 additions & 0 deletions test/Spec.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
main :: IO ()
main = putStrLn "Test suite not yet implemented"

0 comments on commit 0618511

Please sign in to comment.