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

[#1] Add first protocol buffers message and print its serialization to terminal #3

Merged
merged 12 commits into from
Aug 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"