Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Yaron Minsky <yminsky@janestreet.com>
To: Paolo Donadeo <p.donadeo@gmail.com>
Cc: OCaml List <caml-list@inria.fr>,
	Owen Traeholt <otraeholt@janestreet.com>,
	Jeremie Dimino <jdimino@janestreet.com>
Subject: Re: [Caml-list] Compressing stream in Async.Tcp.Server
Date: Thu, 24 Nov 2016 21:39:18 -0500	[thread overview]
Message-ID: <CACLX4jRBFLP=0pLNSy-MB0YajUWVeo-f_p5yjQ2Vz9erBhu85w@mail.gmail.com> (raw)
In-Reply-To: <CAPzAKVBtUPknG8pFMm0xLbcv6gEss2ZZJ5r-GnY2LH23d1FRoQ@mail.gmail.com>

Looping in some folk who work on Async-RPC.

This is a good question. I think there isn't an especially nice
solution for this, but one can write an alternate transport satisfying
this interface:

https://github.com/janestreet/async_rpc_kernel/blob/master/src/transport_intf.ml

that does the compression, which should be enough. But this is not
nicely pre-packaged functionality. It would be nice to have that, and
PRs are certainly welcome...

y

On Thu, Nov 24, 2016 at 12:19 PM, Paolo Donadeo <p.donadeo@gmail.com> wrote:
> Hi all, I'm writing a simple client/server application using Async.Rpc. The
> skeletons of the client and server is essentially derived from the examples
> available on line.
>
> Since the messages are highly compressible, I would like to use ZLib (e.g.
> Cryptokit) but I can't figure out how.
>
> Any ideas?
>
> CLIENT:
>     Tcp.with_connection
>       (Tcp.to_host_and_port host port)
>       ~timeout:(sec 1.)
>       (fun _ r w ->
>         (* COMPRESSION HERE, HOW? *)
>         Rpc.Connection.create r w ~connection_state:Pervasives.ignore
>         >>= function
>         | Error exn -> raise exn
>         | Ok conn   -> begin
>             let msg = {
>               Rpc_protocol.scada_uuid = conf.Config_manager.scada_uuid;
>               measures;
>             } in
>             Rpc.Rpc.dispatch Rpc_protocol.export_data_rpc conn msg >>=
> function
>             | Ok response -> return response
>             | Error e -> begin
>                 error ~tags "SERVER SIDE EXCEPTION";
>                 error ~tags "    %s" (Error.to_string_hum e);
>                 return false
>               end
>           end
>       )
>
>
> SERVER:
>   Tcp.Server.create
>     ~on_handler_error:(`Call (fun _ exn -> Log.Global.sexp (Exn.sexp_of_t
> exn)))
>     (Tcp.on_port port)
>     (fun _addr r w ->
>       (* COMPRESSION HERE, HOW? *)
>       Rpc.Connection.server_with_close r w
>         ~connection_state:(fun c ->
>           {
>             db_thread = db_thread;
>           }
>         )
>         ~on_handshake_error:(
>           `Call (fun exn -> Log.Global.sexp (Exn.sexp_of_t exn); return ()))
>         ~implementations)
>
>
> --
> Paolo

  reply	other threads:[~2016-11-25  2:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-24 17:19 Paolo Donadeo
2016-11-25  2:39 ` Yaron Minsky [this message]
2016-11-25  8:48 ` Francois BERENGER

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACLX4jRBFLP=0pLNSy-MB0YajUWVeo-f_p5yjQ2Vz9erBhu85w@mail.gmail.com' \
    --to=yminsky@janestreet.com \
    --cc=caml-list@inria.fr \
    --cc=jdimino@janestreet.com \
    --cc=otraeholt@janestreet.com \
    --cc=p.donadeo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox