Commit graph

88 commits

Author SHA1 Message Date
intractable
6382857e2c
grpc-haskell-0.2.0.0: Upgrade to proto3-wire-1.2.0, proto3-suite-0.4.2.0 (#110)
* .gitignore

* release.nix: Minor cleanup

* Fix warning

* Expose max receive message length channel arg in `ServiceOptions`

* Fix warning

* Bump upstream dependencies and patch parameterized-0.5.0.0

* grpc-haskell 0.0.1.0 -> 0.0.2.0
2020-11-16 11:43:28 -06:00
Moritz Kiefer
a26497c82c Expose ClientCall in ClientReaderHandler and ClientRWHandler (#87)
This allows you to cancel the call from within the callback using
`clientCallCancel`.
2019-08-22 10:53:41 -05:00
intractable
a818985323
Provide Network.GRPC.HighLevel.Client.simplifyServerStreaming (#82) 2019-08-12 13:03:25 -05:00
j6carey
bc457cc4e3
Shut down server when serverLoop thread is killed. (#71)
Previously, killing the thread running serverLoop
would not actually shut down the server, leading
to file descriptor leaks and perhaps worse effects.
2019-01-07 15:53:10 -08:00
intractable
28288a17b7
Client helpers, re-exports, and fixups (#70)
* Derive `Show` instance for `ClientSSLKeyCertPair`

* Add a couple client helper functions & add additional exports

* Add `grpc-haskell-core` target; add `c2hs` dep

* Fix examples broken by #68

* rm `build-tools` and `include-dirs` directives from toplevel `.cabal`

* More `ClientConfig` fixes

* Ensure examples are built
2018-10-14 17:52:59 -05:00
Ewout
9c6b3f63b6 Fix build on GHC 8.4 (#63)
* Fix haddock: postfix comments on GADT constructors don't work.

See https://github.com/haskell/haddock/issues/43 .

* Remove unused dependencies from cabal file..

* Semigroup instances for compatibility with GHC 8.4.
2018-06-18 12:24:19 -07:00
j6carey
3ee4dabc2d
Add a comment to ClientReaderRequest. (#55)
It was not obvious from the type how many times the
final field of ClientReaderRequest would be invoked.
(Assuming it is invoked once per stream increment
results in a hang, which can be confusing.)
2018-04-02 09:34:35 -07:00
Christian Lavoie
5fd44880da Remove proto3-wire dependency from core package. (#47) 2018-01-30 09:20:05 -08:00
Christian Lavoie
9cfb3da770 Extract lowlevel bits into a core package (#42) 2018-01-29 08:59:34 -08:00
intractable
4a30625a70 Expose ClientError type (#36)
* Expose the max receive message length channel argument + unittest

* `ClientError` GADT ctor => `ClientErrorResponse`, expose `ClientError`

Prior to this commit, the name `ClientError` was both:
  - The name of a data constructor name for the `ClientResult` GADT
  - A name of an internal sum type for capturing different kinds of client
    errors

We want to expose the latter to users of the library, and so expose the latter
and rename the former.

* Remove unused `MultiWayIf` lang ext
2017-10-23 10:11:13 -05:00
intractable
3aa835a6f2 Expose GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH channel arg (#35)
* Expose the max receive message length channel argument + unittest

* Remove unused `MultiWayIf` ext
2017-10-20 16:39:26 -05:00
Olivier Nicole
679e3d7ded Make serverRequestCall interruptible (#30)
Instead of making a blocking foreign call without a timeout, we set a
timeout of one second. This way, the thread returns in Haskell code (and
thus is interruptible) at least every second. This is useful in order to
be able to kill `Server`s, see
https://github.com/awakesecurity/gRPC-haskell/issues/22.
2017-08-21 10:35:05 -05:00
Olivier Nicole
e0c567ec55 Make withServer provide the actual port (#29)
* Make withServer provide the actual port

Again, useful to make a server listen on any available port by giving it
port zero (for testing).

* Re-introduce check on server port

* Add port field to Server

* Style: Remove unneeded newline

* Revert changes in tests
2017-08-21 10:34:30 -05:00
intractable
918e3a8d5a Derive Read instance for StatusCode (#27) 2017-08-05 23:46:12 -05:00
Connor Clark
169dbb7fff First draft of a tutorial (#15)
* add basic tutorial, re-export client stuff in HighLevel.Generated

* add a relative link in README.md

* forgot to document the language extensions

* cabal file fixup

* more context to compile-proto-file

* haskell syntax highlighting in markdown

* link to gRPC official tutorials for basic concepts

* add a note on how to build the examples

* prominent notice of required gRPC version

* fix typo

* do some error handling, show how to run the example executables

* use mapM
2017-04-30 15:38:29 -07:00
Connor Clark
b550607f60 gRPC 1.2.0 compatibility (#12)
* update for reorganized headers in gRPC v1.1: https://github.com/grpc/grpc/pull/7559

* update nix files

* rename all gpr_slice to grpc_slice since we can't be backwards compatible anyway

* use gRPC 1.1.4

* now compatible with gRPC 1.2.0

* use nixpkgs 17.03 to get protobuf3_2, newer proto3-* deps, fix some warnings

* another warning
2017-04-14 19:28:01 -07:00
intractable
4ab231c1d9 Update proto3-suite ref to 8db2ceb8c48a3f8dc2cbdc492d1e8cbaf8b62a15 (#10)
* Update `proto3-suite` gitrev in `stack.yaml` to `8db2ceb8c48a3f8dc2cbdc492d1e8cbaf8b62a15`

* Update `proto3-suite` gitrev in `nix/proto3-suite.nix` to `8db2ceb8c48a3f8dc2cbdc492d1e8cbaf8b62a15`

* Regenerate `Echo.hs` via new `proto3-suite` + `compile-proto-file`

* Remove additional warnings
2017-03-17 07:48:41 -05:00
intractable
5caae587e5 Remove a bunch of compilation warnings. (#9)
* Remove a bunch of compilation warnings

* Fix typo in `cabal configure` invocation
2017-03-16 12:42:51 -05:00
Gabriel Gonzalez
bff8fb7c7e Switch from protobuf-wire to proto3-suite (#92)
`protobuf-wire` was open sourced as `proto3-suite` (with a corresponding module
rename) so this change updates the dependency and import lists
2017-02-27 08:43:37 -08:00
Joel Stanley
9a3be32ed7 Update echo client/server to use CG and high-level interfaces (#88)
* echo client/server example: dead code removal, add command line params, improve output messages

* Add nix-build result to .gitignore

* Merge echo-client and echo-server directories to echo-hs/ directory; rename main modules accordingly

* Use our protobuf compiler to generate bindings for the Echo service

* Simplify echo.proto to just one endpoint; use highlevel client/server interfaces and codegen for echo example

* Remove repetition counts and thread spawns from echo client, parameterize payload

* Update default.nix
2016-12-22 14:33:44 -06:00
Connor Clark
1d8f811906 MONAPP-1369: Server options for generated code. (#76)
* add ServiceOptions for generated servers

* drop opt prefix in ServiceOptions fields

* add default options

* tweak exports, add docs

* re-export stuff from Generated so that users need don't need to import lots of modules

* remove threaded from library -- doesn't do anything

* add defaultServiceOptions export

* more exports

* export GRPCMethodType
2016-11-30 14:22:47 -08:00
Travis Athougies
26dc36dc64 GADT-based high level interface 2016-11-17 16:00:07 -08:00
Phil Freeman
950f4cdefa Add host option to high-level API 2016-10-26 14:43:11 -07:00
Connor Clark
01fac2d5a6 add option to set logging function (#71)
* add option to set logging function

* Add documentation to ServerOptions
2016-08-17 14:12:22 -07:00
Connor Clark
3366dde7ab Connor/security (#68)
* begin security bindings

* secure channel creation

* SSL credentials support

* add client-side ssl support

* ssl test

* read file before passing to channel credentials, free credentials when done creating

* use localhost key/cert for test

* WIP sketch of callbacks for metadata plugins

* conversion from Haskell auth processor to C

* add test for custom server metadata auth processor

* wip auth failure test

* rebase tweak

* working test of custom auth metadata server processor

* improve security docs, clean up

* add unsafe layer client-side auth metadata plugin functionality

* add client config option for custom auth metadata

* WIP client-side metadata auth plugin. Crashing when calling C callback.

* get initial version of client-side metadata plugins working

* replace String with ByteString in a few places, add function for getting AuthProperty

* AuthContext utilities and more documentation

* end-to-end test of client and server auth plugins

* remove redundant tests

* function for parents in unary calls, add deactivated failing test for auth metadata propagation from parent to child

* some cleanup

* tweaks

* more tweaks

* remove unused file

* docs tweak

* consolidate exports

* update protobuf-wire commit
2016-08-17 09:55:06 -07:00
Connor Clark
b9b548d8eb Fix metadata marshalling bug, add QuickCheck properties (#63)
* make metadatamap a newtype of multimap

* update tests for new MetadataMap

* remove multimap dependency, reproduce needed functionality instead

* add repeated key to payload test

* QuickCheck properties for C bindings, fix bug in metadata FFI wrappers

* add quickcheck bound

* fix merge
2016-08-17 09:54:46 -07:00
Joel Stanley
096d399b30 MONAPP-1035: Fix errant hang on metadata exchange in Haskell client-side bidirectional streaming (#70)
* (wip) Change ClientRWHandler to use an IO action for metadata acqui

* Demonstrate placement of WaitForInitialMetadata() in hellos_client

* Make hellos cpp server always send metadata first, for now

* Show getMD placement in haskell hellos-client

* Add prelim bidi metadata exchange behavior tweaks to line up with C++ API conventions
2016-08-15 12:55:40 -05:00
Joel Stanley
a5614befe3 More reuse between unregistered and registered LL server functions (#67) 2016-08-10 16:38:58 -05:00
Joel Stanley
d7b00ac054 Fix race condition while tracking outstanding handler threads (#66)
* Demonstrate shutdown concurrency bug via unregistered server streaming test

* Comments, cleanup

* Remove extraneous liftIOs from low level tests
2016-08-10 16:14:41 -05:00
Joel Stanley
9408745254 Streaming interface tweaks (i.e., StreamSend/Recv ops in IO) (#58)
* Add clientRW', StreamRecv', StreamSend' placeholders for IO-based stream ops (instead of Streaming); concurrent hellos Haskell client; hellos client cleanup

* Fix typo

* Rename clientRW' => clientRW; fix unreg bidi testcase

* Replace serverRW operation with one that uses the IO-based stream ops instead of the Pipes.Proxy.Client ops; modify examples accordingly

* Misc formatting, minor restructuring wibbles

* Replace remaining stream send/recv operations with IO-based ops instead of
Pipes.Proxy.Client; DCR; minor style consistency tweaks.
2016-08-09 11:30:47 -05:00
Connor Clark
d66a4f98b3 Update to gRPC 0.15 (#61)
* update channel arg names, add compression level arg support, add compression level arg test

* switch to temp test demonstrating bug in grpc 0.15.0

* memset op array to 0

* switch examples back

* Switch to newer `grpc` and enable tests in `release.nix`

* Split out `simple-server` test into separate shell script

* Fix bash invocation

* Add intermediate `./default-tests.nix` build

* Add `tests.patch` to version control

* Split `python` command into separate script

* Provide `python` via `nix`
2016-08-05 09:29:20 -07:00
Connor Clark
f8bbe3abd2 Connor/metadata improvements (#52)
* make metadatamap a newtype of multimap

* update tests for new MetadataMap

* remove multimap dependency, reproduce needed functionality instead

* add repeated key to payload test

* bump LTS version for sorted-list, use SortedList for MetadataMap

* remove unneeded conversion

* MetadataMap documentation

* minor fixes
2016-08-01 12:38:35 -07:00
Connor Clark
5a23c9ae90 make serverLoop blocking again (#59) 2016-07-27 16:50:48 -07:00
Connor Clark
0d70a6c960 Criterion benchmarks (#50)
* begin bench executable

* tweak benchmark, fork serverLoop for interruptibility

* client streaming benchmarks

* add server streaming handler

* server streaming benchmark

* bidi streaming benchmark

* cleanup, create benchmark html

* improve error messages

* benchmarks: add bounds, remove -g, add -O2

* eliminate explicit sleep at shutdown

* bump protobuf-wire version

* remove superfluous parens, remove benchmarks.html
2016-07-26 15:48:25 -07:00
Joel Stanley
c1fa7956c7 "Hellos" C++/Haskell programs for exercising interop for streaming modes (#49)
* Hellos example: skeleton and server-streaming mode use

* Catch IO exceptions in dispatchLoop

* Distinguish decoding errors from other errors; convert error calls to explicit throws of GRPCIOErrors

* instance Exception GRPCIOError

* Add error checks and error messages to hellos cpp client

* Change fixed32 to uint32

* Add prelim hellos-client, hellos-server executables

* Hellos cpp example: add client-streaming mode use

* In unregistered high-level server, aggressively catch all exceptions raised in
handlers and promote then to a new GRPCIOError constructor.

* Hellos hs example: add client-streaming mode use

* Hellos cpp example: add simple bidi mode use

* Hellos hs example: add simple bidi mode use

* wibbles

* Add GRPCIOErrorEq newtype wrapper w/ Eq instance for testing purposes

* Refactoring wibbles

* README wibbles

* DCR

* Fix rebase derp

* Remove libdl dep, update protobuf github link in hellos cpp Makefile.

* Use Data.Coerce.coerce for GRPCIOErrorEq; remove warnings

* Report expected/got errors in Haskell hellos client/server

* Report expected/got errors in cpp hellos client/server

* Add some instructions for running the hellos client/server

* Fix warnings

* Rename logShow to logMsg and use stderr for logging

* Tweak compliation parameters for hellos hs executables; increase constant workload

* Remove unnecessary type annotation

* Simplify handleError in dispatchLoop

* Remove GRPCIOErrorEq and coerce use; change GRPCIOHandlerException type
2016-07-26 15:21:35 -07:00
Connor Clark
b3d0b8a4a7 high-level server: add initial metadata to options (#53) 2016-07-26 13:16:44 -07:00
Connor Clark
86bad965ce fix ifdef indentation (#51) 2016-07-22 14:29:05 -07:00
Connor Clark
ab4dea344d Server performance and stability improvements (#48)
* concurrent echo client for stress testing

* update examples for benchmarking, tweak cabal file

* mark frequently-used call as unsafe for performance boost

* add unsafe annotation to non-blocking C calls on critical path

* more unsafe annotations -- server performance almost doubled now

* one CQ for all call ops

* unsafe annotation on start_batch

* wait for all client threads, replace error with fail

* add -O2
2016-07-21 12:55:16 -07:00
Connor Clark
cc5d30acd2 Travis/service generation (#46)
* higher bound on clock versions

* Added helper module for generated service code
2016-07-20 11:26:53 -07:00
Connor Clark
65026eb79c Fix async race causing crash on server shutdown (#43)
* clean up forked threads before shutting down server

* get rid of sleep, wait until all forked threads are dead to shutdown server

* add todo
2016-07-18 11:04:01 -05:00
Connor Clark
99e6f0652d fix up handler type, tweak ServerCall record names (#42)
* fix up handler type, tweak ServerCall record names

* remove ' from handler types, use LL suffix for low-level handlers

* fix all build warnings
2016-07-14 16:33:56 -07:00
Connor Clark
e4a28e9e4b High-level unregistered concurrent interface (#41)
* remove parent ptr from unregistered calls -- unneeded

* begin unregistered high level server loop

* undo changes to highlevel server, add mkConfig for unregistered server

* move call CQ create/destroy into call create/destroy

* async normal call function

* preliminary unregistered server loop for non-streaming methods

* working unregistered highlevel example

* loop counters for benchmarking

* changes for benchmarking, add ruby example server for benchmarking

* async version of withCall, refactor unregistered server loop to handle all method types

* unregistered client streaming

* add remaining streaming modes

* unregistered server streaming test

* unregistered streaming tests

* add error logging

* fix bug in add example

* remove old TODOs

* fix bug: don't assume slices are null-terminated

* add TODO re: unregistered client streaming functions
2016-07-14 09:53:28 -07:00
Connor Clark
9113e416e7 Joel/highlevelv2 (#40)
* Tweak runOps param order, inline common op sequences, clean up serverHandleNormalCall

* More ops sequence inlining for clarity, experimenting with Managed

* Checkpoint: preliminary support for all streaming modes; much cleanup/refactoring and api design still needed

* Use mempty for default StatusDetails; tweak bad status matching mechanism

* Preliminary user-facing, server-streaming, low-level api and test

* renaming wibbles

* Preliminary user-facing, client-streaming, low-level api and test

* Move sendMsgs comb to Network.GRPC.LowLevel.Op; misc cleanup/DCR

* Modify bidi streaming to omit request payload

* Add transformers dep

* Preliminary user-facing low-level bidirectional streaming api and test

* Fix missing peek import

* Remove TimeoutSeconds params on streaming mode functions

* Fix serverHandleNormalCall rebase wart

* Fix rebase warts; minor hlint fixes and wibbles

* Post-rebase tweaks to optional payload use in serverRequestCall (i.e., now respects payloadHandling again)

* Cleanup/refactor serverRequestCall

* Fix comment

* Change ServerRWHandler type so that handler does not have to invoke a finalizer

* Change ServerReaderHandler type so that handler does not have to invoke a finalizer

* Simplify serverWriter interface and ServerWriterHandler structure

* Simplify serverRW (get rid of exec param), improve bidi streaming tests

* Use ExceptT in serverRW impl

* Change ServerRWHandler type to pass recv/send operations.

* Renaming

* Define ClientRWHandler, pass recv/send ops

* wibbles

* Use ExceptT in clientRW impl

* Add DataKinded phantom typing to RegisteredMethod; misc cleanup

* Simplify sendMsgs interface; add SingleSend type and related helpers

* Rename SingleSend to SendSingle, use ExceptT to clean up {client,server}Writer and sendMsgs

* More ExceptT cleanup in clientWriter

* Factor out reusable bits of clientWriter

* Shrink ServerReaderHandler

* Delete stale comments

* begin high-level server interface

* update to datakind representation

* clean up

* move method type info to type level, parametrize ServerCall by payload

* convert for writer handler

* start switching over to Message-based handlers

* begin work on highlevel example

* comment out old code

* parametrize StreamSend

* parametrize StreamRecv

* conversion for ServerReaderHandler

* finish handler conversions

* Add high level version and payload checking to echo-client

* Decouple server CQs from call-bound CQs (registered methods); use more consistent naming conventions

* Decouple server/call-bound CQs for unregistered methods; refactor U.serverRequestCall; misc cleanup

* Make convertRecv total; formatting wibbles
2016-07-12 11:28:21 -07:00
Joel Stanley
2c2c817ad8 Fix botched merge 2016-07-11 15:20:00 -05:00
Joel Stanley
d24f69176b Merge branch 'master' into joel/bugfix/server-request-registered-call-pluck-permission
Conflicts:
	src/Network/GRPC/LowLevel/CompletionQueue.hs
2016-07-11 15:13:34 -05:00
Connor Clark
b7a02a63e7 Fix Linux tests (#38)
* fix debug mode

* handle deadline differently depending on OS

* remove unneeded tests
2016-07-11 11:20:13 -07:00
Joel Stanley
4ae3936ac9 Apply same pluck permission region fix to unregistered serverRequestCall 2016-07-11 12:53:19 -05:00
Joel Stanley
ca1d5a7205 minor tweaks to withPermission 2016-07-10 17:28:10 -05:00
Joel Stanley
a0a14dd7d8 debug wibbles 2016-07-10 17:19:35 -05:00
Joel Stanley
72160cea89 Fixes a concurrency bug wherein a thread (running beyond the maximum number of
pluckers) would register a CQ notification via
grpc_server_request_registered_call prior to obtaining pluck permission, block
on acquiring such permission, and thus miss notification of the server call.

The bug can could be witnessed with particular interleavings by ensuring that
GRPC_MAX_COMPLETION_QUEUE_PLUCKERS server threads are blocked on their own
server call notifications, and then using the
(GRPC_MAX_COMPLETION_QUEUE_PLUCKERS+1)th server thread to attempt to block on a
notification for an additional server call.

In order to fix this, we simply extended the pluck permission held window for
serverRequestCall, and created a variant of pluck (called pluck') which assumes
permission to pluck is already held by the calling thread.
2016-07-10 17:15:57 -05:00