forked from jeffa5/ocaml-grpc
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from dialohq/bugfixes
Merge with bug fixes branch
- Loading branch information
Showing
66 changed files
with
571 additions
and
225 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
version = 0.15.0 | ||
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,4 @@ | ||
(executable | ||
(name service) | ||
(libraries bechamel notty.unix bechamel-notty grpc grpc-lwt ocaml-protoc lwt | ||
lwt.unix h2 h2-lwt-unix bigstringaf)) |
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,73 @@ | ||
open Bechamel | ||
open Toolkit | ||
|
||
let make_buffer capacity = | ||
Staged.stage @@ fun () -> ignore (Grpc.Buffer.v ~capacity ()) | ||
|
||
let make_message len = | ||
Staged.stage @@ fun () -> | ||
ignore (Grpc.Message.make (String.init len (fun _ -> 'a'))) | ||
|
||
let extract_message len = | ||
let msg = Grpc.Message.make (String.init len (fun _ -> 'a')) in | ||
let bs = Bigstringaf.of_string ~off:0 ~len msg in | ||
Staged.stage @@ fun () -> | ||
let buf = Grpc.Buffer.v () in | ||
Grpc.Buffer.copy_from_bigstringaf ~src_off:0 ~src:bs ~dst:buf ~length:len; | ||
ignore (Grpc.Message.extract buf) | ||
|
||
let test_buffer = | ||
Test.make_indexed ~name:"buffer" ~fmt:"%s %d" | ||
~args:[ 0; 512; 1024; 2048; 4096; 8192 ] | ||
make_buffer | ||
|
||
let test_message = | ||
Test.make_indexed ~name:"message" ~fmt:"%s %d" | ||
~args:[ 0; 32; 64; 128; 256; 512 ] | ||
make_message | ||
|
||
let test_extract = | ||
Test.make_indexed ~name:"extract" ~fmt:"%s %d" | ||
~args:[ 0; 32; 64; 128; 256; 512 ] | ||
extract_message | ||
|
||
let benchmark () = | ||
let ols = | ||
Analyze.ols ~bootstrap:0 ~r_square:true ~predictors:Measure.[| run |] | ||
in | ||
let instances = | ||
Instance.[ minor_allocated; major_allocated; monotonic_clock ] | ||
in | ||
let cfg = | ||
Benchmark.cfg ~limit:2000 ~quota:(Time.second 0.5) ~kde:(Some 1000) () | ||
in | ||
let raw_results = | ||
Benchmark.all cfg instances | ||
(Test.make_grouped ~name:"make" ~fmt:"%s %s" | ||
[ test_buffer; test_message; test_extract ]) | ||
in | ||
let results = | ||
List.map (fun instance -> Analyze.all ols instance raw_results) instances | ||
in | ||
let results = Analyze.merge ols instances results in | ||
(results, raw_results) | ||
|
||
let () = | ||
List.iter | ||
(fun v -> Bechamel_notty.Unit.add v (Measure.unit v)) | ||
Instance.[ minor_allocated; major_allocated; monotonic_clock ] | ||
|
||
let img (window, results) = | ||
Bechamel_notty.Multiple.image_of_ols_results ~rect:window | ||
~predictor:Measure.run results | ||
|
||
open Notty_unix | ||
|
||
let () = | ||
let window = | ||
match winsize Unix.stdout with | ||
| Some (w, h) -> { Bechamel_notty.w; h } | ||
| None -> { Bechamel_notty.w = 80; h = 1 } | ||
in | ||
let results, _ = benchmark () in | ||
img (window, results) |> eol |> output_image |
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,2 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Rpc (grpc-lwt.Grpc_lwt.Client.Rpc)</title><link rel="stylesheet" href="../../../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 1.5.2"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="content"><header><nav><a href="../index.html">Up</a> – <a href="../../../index.html">grpc-lwt</a> » <a href="../../index.html">Grpc_lwt</a> » <a href="../index.html">Client</a> » Rpc</nav><h1>Module <code>Client.Rpc</code></h1></header><dl><dt class="spec type" id="type-handler"><a href="#type-handler" class="anchor"></a><code><span class="keyword">type</span> <span>'a handler</span></code><code> = <span><span><span>[ `write ]</span> H2.Body.t</span> Lwt.t</span> <span>-></span> <span><span>[ `read ]</span> H2.Body.t</span> <span>-></span> <span><span class="type-var">'a</span> Lwt.t</span></code></dt></dl><dl><dt class="spec value" id="val-bidirectional_streaming"><a href="#val-bidirectional_streaming" class="anchor"></a><code><span class="keyword">val</span> bidirectional_streaming : <span>f:<span>(<span>(Pbrt.Encoder.t <span>-></span> unit)</span> <span>-></span> <span>Pbrt.Decoder.t Lwt_stream.t</span> <span>-></span> <span><span class="type-var">'a</span> Lwt.t</span>)</span></span> <span>-></span> <span><span class="type-var">'a</span> <a href="index.html#type-handler">handler</a></span></code></dt><dd><p><code>bidirectional_streaming ~f write read</code> sets up the sending and receiving logic using <code>write</code> and <code>read</code>, then calls <code>f</code> with a push function for requests and a stream of responses.</p></dd></dl><dl><dt class="spec value" id="val-client_streaming"><a href="#val-client_streaming" class="anchor"></a><code><span class="keyword">val</span> client_streaming : <span>f:<span>(<span>(Pbrt.Encoder.t <span>-></span> unit)</span> <span>-></span> <span><span>Pbrt.Decoder.t option</span> Lwt.t</span> <span>-></span> <span><span class="type-var">'a</span> Lwt.t</span>)</span></span> <span>-></span> <span><span class="type-var">'a</span> <a href="index.html#type-handler">handler</a></span></code></dt><dd><p><code>client_streaming ~f write read</code> sets up the sending and receiving logic using <code>write</code> and <code>read</code>, then calls <code>f</code> with a push function for requests and promise for the response.</p></dd></dl><dl><dt class="spec value" id="val-server_streaming"><a href="#val-server_streaming" class="anchor"></a><code><span class="keyword">val</span> server_streaming : <span>f:<span>(<span>Pbrt.Decoder.t Lwt_stream.t</span> <span>-></span> <span><span class="type-var">'a</span> Lwt.t</span>)</span></span> <span>-></span> Pbrt.Encoder.t <span>-></span> <span><span class="type-var">'a</span> <a href="index.html#type-handler">handler</a></span></code></dt><dd><p><code>server_streaming ~f enc write read</code> sets up the sending and receiving logic using <code>write</code> and <code>read</code>, then sends <code>enc</code> and calls <code>f</code> with a stream of responses.</p></dd></dl><dl><dt class="spec value" id="val-unary"><a href="#val-unary" class="anchor"></a><code><span class="keyword">val</span> unary : <span>f:<span>(<span><span>Pbrt.Decoder.t option</span> Lwt.t</span> <span>-></span> <span><span class="type-var">'a</span> Lwt.t</span>)</span></span> <span>-></span> Pbrt.Encoder.t <span>-></span> <span><span class="type-var">'a</span> <a href="index.html#type-handler">handler</a></span></code></dt><dd><p><code>unary ~f enc write read</code> sets up the sending and receiving logic using <code>write</code> and <code>read</code>, then sends <code>enc</code> and calls <code>f</code> with a promise for the response.</p></dd></dl></div></body></html> |
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,2 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Client (grpc-lwt.Grpc_lwt.Client)</title><link rel="stylesheet" href="../../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 1.5.2"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="content"><header><nav><a href="../index.html">Up</a> – <a href="../../index.html">grpc-lwt</a> » <a href="../index.html">Grpc_lwt</a> » Client</nav><h1>Module <code>Grpc_lwt.Client</code></h1></header><div class="spec module" id="module-Rpc"><a href="#module-Rpc" class="anchor"></a><code><span class="keyword">module</span> <a href="Rpc/index.html">Rpc</a> : <span class="keyword">sig</span> ... <span class="keyword">end</span></code></div><dl><dt class="spec type" id="type-response_handler"><a href="#type-response_handler" class="anchor"></a><code><span class="keyword">type</span> response_handler</code><code> = H2.Client_connection.response_handler</code></dt><dt class="spec type" id="type-do_request"><a href="#type-do_request" class="anchor"></a><code><span class="keyword">type</span> do_request</code><code> = <span>?⁠trailers_handler:<span>(H2.Headers.t <span>-></span> unit)</span></span> <span>-></span> H2.Request.t <span>-></span> <span>response_handler:<a href="index.html#type-response_handler">response_handler</a></span> <span>-></span> <span><span>[ `write ]</span> H2.Body.t</span></code></dt><dd><p><code>do_request</code> is the type of a function that performs the request</p></dd></dl><dl><dt class="spec value" id="val-call"><a href="#val-call" class="anchor"></a><code><span class="keyword">val</span> call : <span>service:string</span> <span>-></span> <span>rpc:string</span> <span>-></span> <span>?⁠scheme:string</span> <span>-></span> <span>handler:<span><span class="type-var">'a</span> <a href="Rpc/index.html#type-handler">Rpc.handler</a></span></span> <span>-></span> <span>do_request:<a href="index.html#type-do_request">do_request</a></span> <span>-></span> unit <span>-></span> <span><span><span>(<span class="type-var">'a</span> * <a href="../../../grpc/Grpc/Status/index.html#type-t">Grpc.Status.t</a>, <a href="../../../grpc/Grpc/Status/index.html#type-t">Grpc.Status.t</a>)</span> Stdlib.result</span> Lwt.t</span></code></dt><dd><p><code>call ~service ~rpc ~handler ~do_request ()</code> calls the rpc endpoint given by <code>service</code> and <code>rpc</code> using the <code>do_request</code> function. The <code>handler</code> is called when this request is set up to send and receive data.</p></dd></dl></div></body></html> |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.