blob: 4fe4b675d9b9ca4ccc37740ffc44dc790e60739a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
(* Unison file synchronizer: src/remote.mli *)
(* Copyright 1999-2018, Benjamin C. Pierce (see COPYING for details) *)
module Thread : sig
val unwindProtect : (unit -> 'a Lwt.t) -> (exn -> unit Lwt.t) -> 'a Lwt.t
end
(* Register a server function. The result is a function that takes a host
name as argument and either executes locally or else communicates with a
remote server, as appropriate. (Calling registerServerCmd also has the
side effect of registering the command under the given name, so that when
we are running as a server it can be looked up and executed when
requested by a remote client.) *)
val registerHostCmd :
string (* command name *)
-> ('a -> 'b Lwt.t) (* local command *)
-> ( string (* -> host *)
-> 'a (* arguments *)
-> 'b Lwt.t) (* -> (suspended) result *)
(* A variant of registerHostCmd, for constructing a remote command to be
applied to a particular root (host + fspath).
-
A naming convention: when a `root command' is built from a
corresponding `local command', we name the two functions
<funcName>OnRoot and <funcName>Local *)
val registerRootCmd :
string (* command name *)
-> ((Fspath.t * 'a) -> 'b Lwt.t) (* local command *)
-> ( Common.root (* -> root *)
-> 'a (* additional arguments *)
-> 'b Lwt.t) (* -> (suspended) result *)
(* Test whether a command exits on some root *)
val commandAvailable :
Common.root -> (* root *)
string -> (* command name *)
bool Lwt.t
(* Enter "server mode", reading and processing commands from a remote
client process until killed *)
val beAServer : unit -> unit
val waitOnPort : string option -> string -> unit
(* Whether the server should be killed when the client terminates *)
val killServer : bool Prefs.t
(* Establish a connection to the remote server (if any) corresponding
to the root and return the canonical name of the root *)
val canonizeRoot :
string -> Clroot.clroot -> (string -> string -> string) option ->
Common.root Lwt.t
(* Statistics *)
val emittedBytes : float ref
val receivedBytes : float ref
(* Establish a connection to the server.
First call openConnectionStart, then loop:
call openConnectionPrompt, if you get a prompt,
respond with openConnectionReply if desired.
After you get None from openConnectionPrompt,
call openConnectionEnd.
Call openConnectionCancel to abort the connection.
*)
type preconnection
val openConnectionStart : Clroot.clroot -> preconnection option
val openConnectionPrompt : preconnection -> string option
val openConnectionReply : preconnection -> string -> unit
val openConnectionEnd : preconnection -> unit
val openConnectionCancel : preconnection -> unit
(* return the canonical name of the root. The connection
to the root must have already been established by
the openConnection sequence. *)
val canonize : Clroot.clroot -> Common.root
(****)
type msgId = int
module MsgIdMap : Map.S with type key = msgId
val newMsgId : unit -> msgId
type connection
val connectionToRoot : Common.root -> connection
val registerServerCmd :
string -> (connection -> 'a -> 'b Lwt.t) -> connection -> 'a -> 'b Lwt.t
val registerSpecialServerCmd :
string ->
('a ->
(Bytearray.t * int * int) list -> (Bytearray.t * int * int) list * int) *
(Bytearray.t -> int -> 'a) ->
('b ->
(Bytearray.t * int * int) list -> (Bytearray.t * int * int) list * int) *
(Bytearray.t -> int -> 'b) ->
(connection -> 'a -> 'b Lwt.t) -> connection -> 'a -> 'b Lwt.t
val defaultMarshalingFunctions :
('a ->
(Bytearray.t * int * int) list -> (Bytearray.t * int * int) list * int) *
(Bytearray.t -> int -> 'b)
val intSize : int
val encodeInt : int -> Bytearray.t * int * int
val decodeInt : Bytearray.t -> int -> int
val registerRootCmdWithConnection :
string (* command name *)
-> (connection -> 'a -> 'b Lwt.t) (* local command *)
-> Common.root (* root on which the command is executed *)
-> Common.root (* other root *)
-> 'a (* additional arguments *)
-> 'b Lwt.t (* result *)
val streamingActivated : bool Prefs.t
val registerStreamCmd :
string ->
('a ->
(Bytearray.t * int * int) list -> (Bytearray.t * int * int) list * int) *
(Bytearray.t -> int -> 'a) ->
(connection -> 'a -> unit) ->
connection -> (('a -> unit Lwt.t) -> 'b Lwt.t) -> 'b Lwt.t
|