Skip to content

Commit

Permalink
[RPC] remove dead code related to --persistent
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
  • Loading branch information
rgrinberg committed Jun 2, 2021
1 parent 6ddf43e commit 0501664
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 104 deletions.
7 changes: 0 additions & 7 deletions otherlibs/dune-rpc/dune_rpc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,5 @@ module V1 = struct
-> Initialize.t
-> f:(t -> 'a fiber)
-> 'a fiber

val connect_persistent :
?on_disconnect:('a -> unit fiber)
-> chan
-> on_connect:(unit -> ('a * Initialize.t * Handler.t option) fiber)
-> on_connected:('a -> t -> unit fiber)
-> unit fiber
end
end
7 changes: 0 additions & 7 deletions otherlibs/dune-rpc/dune_rpc.mli
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,6 @@ module V1 : sig
-> Initialize.t
-> f:(t -> 'a fiber)
-> 'a fiber

val connect_persistent :
?on_disconnect:('a -> unit fiber)
-> chan
-> on_connect:(unit -> ('a * Initialize.t * Handler.t option) fiber)
-> on_connected:('a -> t -> unit fiber)
-> unit fiber
end

(** Functor to create a client implementation *)
Expand Down
62 changes: 0 additions & 62 deletions otherlibs/dune-rpc/private/dune_rpc_private.ml
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,6 @@ module type S = sig
-> Initialize.Request.t
-> f:(t -> 'a fiber)
-> 'a fiber

val connect_persistent :
?on_disconnect:('a -> unit fiber)
-> chan
-> on_connect:(unit -> ('a * Initialize.Request.t * Handler.t option) fiber)
-> on_connected:('a -> t -> unit fiber)
-> unit fiber
end

module Client (Fiber : sig
Expand Down Expand Up @@ -512,9 +505,6 @@ struct
; mutable closed_write : bool
}

let make read write =
{ read; write; closed_read = false; closed_write = false }

let of_chan c =
{ read = (fun () -> Chan.read c)
; write = (fun s -> Chan.write c s)
Expand All @@ -533,8 +523,6 @@ struct
t.write None
)

let close_read t = t.closed_read <- true

let read t =
if t.closed_read then
Fiber.return None
Expand Down Expand Up @@ -843,56 +831,6 @@ struct
in
connect_raw chan initialize ~f ~on_notification

let connect_persistent ?(on_disconnect = fun _ -> Fiber.return ()) chan
~on_connect ~on_connected =
let chan = Chan.of_chan chan in
let packets () =
let+ read = Chan.read chan in
Option.map read ~f:(fun sexp ->
match Conv.of_sexp Persistent.In.sexp sexp ~version:(0, 0) with
| Ok m -> m
| Error e -> raise (Invalid_session e))
in
let make_chan packets =
let read () =
let+ packet = packets () in
match (packet : Persistent.In.t option) with
| None
| Some Close_connection ->
None
| Some (Packet csexp) -> Some csexp
| Some New_connection ->
Code_error.raise "Unexpected new connection." []
in
let write p =
let packets =
match p with
| Some p -> List.map p ~f:(fun p -> Persistent.Out.Packet p)
| None -> [ Close_connection ]
in
let sexps = List.map packets ~f:(Conv.to_sexp Persistent.Out.sexp) in
Chan.write chan (Some sexps)
in
Chan.make read write
in
let rec loop () =
let* packet = packets () in
match packet with
| Some New_connection ->
let* a, init, handler = on_connect () in
let chan = make_chan packets in
let* () = connect ?handler chan init ~f:(on_connected a) in
Chan.close_read chan;
let* () = on_disconnect a in
loop ()
| Some Close_connection -> loop ()
| None -> Fiber.return ()
| Some (Packet p) ->
Code_error.raise "Expected new connection"
[ ("received", Sexp.to_dyn p) ]
in
loop ()
let connect_raw chan init ~on_notification ~f =
let chan = Chan.of_chan chan in
connect_raw chan init ~on_notification ~f
Expand Down
28 changes: 0 additions & 28 deletions otherlibs/dune-rpc/private/dune_rpc_private.mli
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,6 @@ module type S = sig
-> Initialize.Request.t
-> f:(t -> 'a fiber)
-> 'a fiber

val connect_persistent :
?on_disconnect:('a -> unit fiber)
-> chan
-> on_connect:(unit -> ('a * Initialize.Request.t * Handler.t option) fiber)
-> on_connected:('a -> t -> unit fiber)
-> unit fiber
end

module Client (Fiber : sig
Expand Down Expand Up @@ -342,27 +335,6 @@ end) (Chan : sig
val read : t -> Csexp.t option Fiber.t
end) : S with type 'a fiber := 'a Fiber.t and type chan := Chan.t

module Persistent : sig
module In : sig
(** The type of incoming packets when hosting multiple connections in
sequence over a single channel *)
type t =
| New_connection
| Packet of Csexp.t
| Close_connection

val sexp : t Conv.value
end

module Out : sig
type t =
| Packet of Csexp.t
| Close_connection

val sexp : t Conv.value
end
end

module Packet : sig
module Reply : sig
type t =
Expand Down

0 comments on commit 0501664

Please sign in to comment.