Skip to content

Commit eab97d3

Browse files
authored
Merge pull request #342 from samoht/remove-labels
Remove labels
2 parents b57f635 + f82baca commit eab97d3

26 files changed

+140
-168
lines changed

bench/cost.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ module Fake_protocol2 = struct
8686
let close _ = Ok ()
8787
end
8888

89-
let fake0 = Tuyau.register ~protocol:(module Fake_protocol0)
89+
let fake0 = Tuyau.register (module Fake_protocol0)
9090

91-
let fake1 = Tuyau.register ~protocol:(module Fake_protocol1)
91+
let fake1 = Tuyau.register (module Fake_protocol1)
9292

93-
let fake2 = Tuyau.register ~protocol:(module Fake_protocol2)
93+
let fake2 = Tuyau.register (module Fake_protocol2)
9494

9595
let hello_world = "Hello World!\n"
9696

src/async-ssl/conduit_async_ssl.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ let protocol_with_ssl :
189189
let writer = writer
190190
end in
191191
let module M = Protocol (Flow) in
192-
Conduit_async.register ~protocol:(module M)
192+
Conduit_async.register (module M)
193193

194194
module Make (Service : sig
195195
include Conduit_async.SERVICE
@@ -279,11 +279,11 @@ end
279279

280280
let service_with_ssl :
281281
type cfg edn t flow.
282-
(cfg, t, flow) Conduit_async.Service.service ->
282+
(cfg, t, flow) Conduit_async.Service.t ->
283283
reader:(flow -> Reader.t) ->
284284
writer:(flow -> Writer.t) ->
285285
(edn, flow with_ssl) Conduit_async.protocol ->
286-
(context * cfg, context * t, flow with_ssl) Conduit_async.Service.service =
286+
(context * cfg, context * t, flow with_ssl) Conduit_async.Service.t =
287287
fun service ~reader ~writer protocol ->
288288
let module S = (val Conduit_async.Service.impl service) in
289289
let module Service = struct
@@ -294,7 +294,7 @@ let service_with_ssl :
294294
let writer = writer
295295
end in
296296
let module M = Make (Service) in
297-
Conduit_async.Service.register ~service:(module M) ~protocol
297+
Conduit_async.Service.register (module M) protocol
298298

299299
module TCP = struct
300300
open Conduit_async.TCP

src/async-ssl/conduit_async_ssl.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ val protocol_with_ssl :
5050
(context * 'edn, 'flow with_ssl) protocol
5151

5252
val service_with_ssl :
53-
('cfg, 't, 'flow) Service.service ->
53+
('cfg, 't, 'flow) Service.t ->
5454
reader:('flow -> Reader.t) ->
5555
writer:('flow -> Writer.t) ->
5656
('edn, 'flow with_ssl) protocol ->
57-
(context * 'cfg, context * 't, 'flow with_ssl) Service.service
57+
(context * 'cfg, context * 't, 'flow with_ssl) Service.t
5858

5959
(** {2 Composition between Host's TCP/IP stack protocol and SSL.} *)
6060

src/async-tls/conduit_async_tls.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ val protocol_with_tls :
1515
type 'service service_with_tls
1616

1717
val service_with_tls :
18-
('cfg, 't, 'flow) Service.service ->
18+
('cfg, 't, 'flow) Service.t ->
1919
('edn, 'flow protocol_with_tls) protocol ->
2020
( 'cfg * Tls.Config.server,
2121
't service_with_tls,
2222
'flow protocol_with_tls )
23-
Service.service
23+
Service.t
2424

2525
(** {2 Composition between Host's TCP/IP stack protocol and TLS.} *)
2626

src/async/conduit_async.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ let failwith fmt = Format.kasprintf failwith fmt
1313

1414
let ( >>? ) x f = Async.Deferred.Result.bind x ~f
1515

16-
type ('a, 'b, 'c) service = ('a, 'b, 'c) Service.service
16+
type ('a, 'b, 'c) service = ('a, 'b, 'c) Service.t
1717

1818
let serve :
1919
type cfg t v.
2020
?timeout:int ->
2121
handler:(flow -> unit Async.Deferred.t) ->
22-
service:(cfg, t, v) service ->
22+
(cfg, t, v) service ->
2323
cfg ->
2424
unit Async.Condition.t * (unit -> unit Async.Deferred.t) =
25-
fun ?timeout ~handler ~service cfg ->
25+
fun ?timeout ~handler service cfg ->
2626
let open Async in
2727
let stop = Async.Condition.create () in
2828
let module Svc = (val Service.impl service) in
2929
let main () =
30-
Service.init cfg ~service >>= function
30+
Service.init service cfg >>= function
3131
| Error err -> failwith "%a" Service.pp_error err
3232
| Ok t -> (
3333
let rec loop () =
@@ -180,7 +180,7 @@ module TCP = struct
180180
Writer.close writer >>= fun () -> Async.return (Ok ()))
181181
end
182182

183-
let protocol = register ~protocol:(module Protocol)
183+
let protocol = register (module Protocol)
184184

185185
type configuration =
186186
| Listen : int option * ('a, 'b) Tcp.Where_to_listen.t -> configuration
@@ -246,7 +246,7 @@ module TCP = struct
246246
Fd.close (Socket.fd socket) >>= fun () -> Async.return (Ok ())
247247
end
248248

249-
let service = S.register ~service:(module Service) ~protocol
249+
let service = S.register (module Service) protocol
250250

251251
let resolve ~port = function
252252
| Conduit.Endpoint.IP ip ->

src/async/conduit_async.mli

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ include
1010
and type output = Cstruct.t
1111
and type +'a io = 'a Async.Deferred.t
1212

13-
type ('a, 'b, 'c) service = ('a, 'b, 'c) Service.service
13+
type ('a, 'b, 'c) service = ('a, 'b, 'c) Service.t
1414
(** The type for async services. *)
1515

1616
val serve :
1717
?timeout:int ->
1818
handler:(flow -> unit Async.Deferred.t) ->
19-
service:('cfg, 't, 'v) service ->
19+
('cfg, 't, 'v) service ->
2020
'cfg ->
2121
unit Async.Condition.t * (unit -> unit Async.Deferred.t)
22-
(** [serve ~handler ~service cfg] creates an usual infinite [service] loop from
23-
the given configuration ['cfg]. It returns the {i promise} to launch the
24-
loop and a condition variable to stop the loop.
22+
(** [serve ~handler t cfg] creates an infinite service loop from the given
23+
configuration ['cfg]. It returns the {i promise} to launch the loop and a
24+
condition variable to stop the loop.
2525
2626
{[
27-
let stop, loop = serve ~handler ~service:TCP.service cfg in
27+
let stop, loop = serve ~handler TCP.service cfg in
2828
Async_unix.Signal.handle [ Core.Signal.int ] ~f:(fun _sig ->
2929
Async.Condition.broadcast stop ()) ;
3030
loop ()

src/core/conduit.ml

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,8 @@ module Make (IO : IO) (Input : BUFFER) (Output : BUFFER) :
171171
| Ok _ as v -> v
172172
| Error err -> Error (`Msg (strf "%a" Protocol.pp_error err))
173173

174-
let register :
175-
type edn flow. protocol:(edn, flow) impl -> (edn, flow) protocol =
176-
fun ~protocol ->
174+
let register : type edn flow. (edn, flow) impl -> (edn, flow) protocol =
175+
fun protocol ->
177176
let key = Map.Key.create "" in
178177
Ptr.inj (Protocol (key, protocol))
179178

@@ -365,17 +364,15 @@ module Make (IO : IO) (Input : BUFFER) (Output : BUFFER) :
365364

366365
module Svc = E0.Make (F)
367366

368-
type ('cfg, 't, 'flow) service =
367+
type ('cfg, 't, 'flow) t =
369368
| Service :
370369
('cfg, 't, 'flow) thd Svc.s * (_, 'flow) protocol
371-
-> ('cfg, 't, 'flow) service
370+
-> ('cfg, 't, 'flow) t
372371

373372
let register :
374-
type cfg t flow.
375-
service:(cfg, t, flow) impl ->
376-
protocol:(_, flow) protocol ->
377-
(cfg, t, flow) service =
378-
fun ~service ~protocol ->
373+
type cfg s flow.
374+
(cfg, s, flow) impl -> (_, flow) protocol -> (cfg, s, flow) t =
375+
fun service protocol ->
379376
let cfg = Map.Key.create "" in
380377
Service (Svc.inj (Svc (cfg, service)), protocol)
381378

@@ -385,48 +382,45 @@ module Make (IO : IO) (Input : BUFFER) (Output : BUFFER) :
385382

386383
let equal :
387384
type a b c d e f.
388-
(a, b, c) service ->
389-
(d, e, f) service ->
385+
(a, b, c) t ->
386+
(d, e, f) t ->
390387
((a, d) refl * (b, e) refl * (c, f) refl) option =
391388
fun (Service ((module A), _)) (Service ((module B), _)) ->
392389
match A.Id with B.Id -> Some (Refl, Refl, Refl) | _ -> None
393390

394391
let init :
395-
type cfg t flow.
396-
cfg -> service:(cfg, t, flow) service -> (t, [> error ]) result io =
397-
fun edn ~service:(Service ((module Witness), _)) ->
392+
type cfg s flow. (cfg, s, flow) t -> cfg -> (s, [> error ]) result io =
393+
fun (Service ((module Witness), _)) cfg ->
398394
let (Svc (_, (module Service))) = Witness.witness in
399-
Service.init edn >>= function
395+
Service.init cfg >>= function
400396
| Ok t -> return (Ok t)
401397
| Error err -> return (error_msgf "%a" Service.pp_error err)
402398

403399
let accept :
404-
type cfg t v.
405-
service:(cfg, t, v) service -> t -> (flow, [> error ]) result io =
406-
fun ~service:(Service ((module Witness), protocol)) t ->
400+
type cfg s v. (cfg, s, v) t -> s -> (flow, [> error ]) result io =
401+
fun (Service ((module Witness), protocol)) t ->
407402
let (Svc (_, (module Service))) = Witness.witness in
408403
Service.accept t >>= function
409404
| Ok flow -> return (Ok (pack protocol flow))
410405
| Error err -> return (error_msgf "%a" Service.pp_error err)
411406

412407
let close :
413-
type cfg t flow.
414-
service:(cfg, t, flow) service -> t -> (unit, [> error ]) result io =
415-
fun ~service:(Service ((module Witness), _)) t ->
408+
type cfg s flow. (cfg, s, flow) t -> s -> (unit, [> error ]) result io =
409+
fun (Service ((module Witness), _)) t ->
416410
let (Svc (_, (module Service))) = Witness.witness in
417411
Service.close t >>= function
418412
| Ok () -> return (Ok ())
419413
| Error err -> return (error_msgf "%a" Service.pp_error err)
420414

421-
let pack : type v. (_, _, v) service -> v -> flow =
415+
let pack : type v. (_, _, v) t -> v -> flow =
422416
fun (Service (_, protocol)) flow -> pack protocol flow
423417

424418
let impl :
425-
type cfg t flow.
426-
(cfg, t, flow) service ->
419+
type cfg s flow.
420+
(cfg, s, flow) t ->
427421
(module SERVICE
428422
with type configuration = cfg
429-
and type t = t
423+
and type t = s
430424
and type flow = flow) =
431425
fun (Service ((module S), _)) ->
432426
let (Svc (_, (module Service))) = S.witness in

src/core/conduit_intf.ml

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,9 @@ module type S = sig
206206
Endpoints allow users to create flows by either connecting directly to a
207207
remote server or by resolving domain names (with {!connect}). *)
208208

209-
val register : protocol:('edn, 'flow) impl -> ('edn, 'flow) protocol
210-
(** [register ~protocol] is the protocol using the implementation [protocol].
211-
[protocol] must provide a [connect] function to allow client flows to be
212-
created.
209+
val register : ('edn, 'flow) impl -> ('edn, 'flow) protocol
210+
(** [register i] is the protocol using the implementation [i]. [protocol] must
211+
provide a [connect] function to allow client flows to be created.
213212
214213
For instance, on Unix, [Conduit] clients will use [Unix.sockaddr] as flow
215214
endpoints, while [Unix.file_descr] would be used for the flow transport.
@@ -218,7 +217,7 @@ module type S = sig
218217
module Conduit_tcp : sig
219218
val t : (Unix.sockaddr, Unix.file_descr) protocol
220219
end = struct
221-
let t = register ~protocol:(module TCP)
220+
let t = register (module TCP)
222221
end
223222
]}
224223
@@ -230,7 +229,7 @@ module type S = sig
230229
module Conduit_tcp_tls : sig
231230
val t : (Unix.sockaddr * Tls.Config.client, Unix.file_descr) protocol
232231
end = struct
233-
let t = register ~protocol:(module TLS)
232+
let t = register (module TLS)
234233
end
235234
]}
236235
@@ -281,7 +280,7 @@ module type S = sig
281280
282281
val t : (Unix.sockaddr, Unix.file_descr) protocol
283282
end = struct
284-
let t = register ~protocol:(module TCP)
283+
let t = register (module TCP)
285284
286285
include (val Conduit.repr t)
287286
end
@@ -430,34 +429,30 @@ module type S = sig
430429
and type t = 't
431430
and type flow = 'flow)
432431

433-
type ('cfg, 't, 'flow) service
432+
type ('cfg, 't, 'flow) t
434433
(** The type for services, e.g. service-side protocols. ['cfg] is the type
435-
for configuration, ['t] is the type for state states. ['flow] is the
434+
for configuration, ['s] is the type for server states. ['flow] is the
436435
type for underlying flows. *)
437436

438437
val equal :
439-
('cfg0, 't0, 'flow0) service ->
440-
('cfg1, 't1, 'flow1) service ->
438+
('cfg0, 't0, 'flow0) t ->
439+
('cfg1, 't1, 'flow1) t ->
441440
(('cfg0, 'cfg1) refl * ('t0, 't1) refl * ('flow0, 'flow1) refl) option
442441
(** [equal svc0 svc1] proves that [svc0] and [svc1] are physically the same.
443442
For instance, [Conduit] asserts:
444443
445444
{[
446-
let service = Service.register ~service:(module V) ;;
445+
let service = Service.register (module V) protocol ;;
447446
448447
let () = match Service.equal service service with
449448
| Some (Refl, Refl, Refl) -> ...
450449
| _ -> assert false
451450
]} *)
452451

453-
val register :
454-
service:('cfg, 't, 'v) impl ->
455-
protocol:(_, 'v) protocol ->
456-
('cfg, 't, 'v) service
457-
(** [register ~service ~protocool] is the service using the implementation
458-
[service] bound with implementation of a [protocol]. [service] must
459-
define [make] and [accept] function to be able to create server-side
460-
flows.
452+
val register : ('cfg, 't, 'v) impl -> (_, 'v) protocol -> ('cfg, 't, 'v) t
453+
(** [register i p] is the service using the implementation [i] using the
454+
protocol [p]. [i] should define a [make] and an [accept] function to
455+
create server-side flows.
461456
462457
For instance:
463458
@@ -466,30 +461,26 @@ module type S = sig
466461
and type t = Unix.file_descr
467462
and type flow = Unix.file_descr
468463
469-
let tcp_protocol = Conduit.register ~protocol:(module TCP_protocol)
464+
let tcp_protocol = Conduit.register (module TCP_protocol)
470465
let tcp_service : (Unix.sockaddr, Unix.file_descr, Unix.file_descr) Service.service =
471-
Conduit.Service.register ~service:(module TCP_service) ~protocol:tcp_protocol
466+
Conduit.Service.register (module TCP_service) tcp_protocol
472467
]} *)
473468

474469
type error = [ `Msg of string ]
475470

476471
val pp_error : error Fmt.t
477472

478-
val init :
479-
'cfg -> service:('cfg, 't, 'v) service -> ('t, [> error ]) result io
480-
(** [init cfg ~service] initialises the service with the configuration
481-
[cfg]. *)
473+
val init : ('cfg, 't, 'v) t -> 'cfg -> ('t, [> error ]) result io
474+
(** [init t cfg] initialises the service with the configuration [cfg]. *)
482475

483-
val accept :
484-
service:('cfg, 't, 'v) service -> 't -> (flow, [> error ]) result io
485-
(** [accept service t] waits for a connection on the service [t]. The result
486-
is a {i flow} connected to the client. *)
476+
val accept : ('cfg, 's, 'v) t -> 's -> (flow, [> error ]) result io
477+
(** [accept t s] waits for a connection on the server [s]. The result is a
478+
{i flow} connected to the client. *)
487479

488-
val close :
489-
service:('cfg, 't, 'v) service -> 't -> (unit, [> error ]) result io
490-
(** [close ~service t] releases the resources associated to the server [t]. *)
480+
val close : ('cfg, 's, 'v) t -> 's -> (unit, [> error ]) result io
481+
(** [close t s] releases the resources associated to the server [s]. *)
491482

492-
val pack : (_, _, 'v) service -> 'v -> flow
483+
val pack : (_, _, 'v) t -> 'v -> flow
493484
(** [pack service v] returns the abstracted value [v] as {!pack} does for a
494485
given protocol {i witness} (bound with the given [service]). It serves
495486
to abstract the flow created (and initialised) by the service to a
@@ -500,7 +491,7 @@ module type S = sig
500491
Conduit.send flow "Hello World!" >>= fun _ ->
501492
...
502493
503-
let run ~service cfg =
494+
let run service cfg =
504495
let module Service = Conduit.Service.impl service in
505496
Service.init cfg >>? fun t ->
506497
let rec loop t =
@@ -509,12 +500,12 @@ module type S = sig
509500
async (fun () -> handler flow) ; loop t in
510501
loop t
511502
512-
let () = run ~service:tcp_service (localhost, 8080)
513-
let () = run ~service:tls_service (certs, (localhost, 8080))
503+
let () = run tcp_service (localhost, 8080)
504+
let () = run tls_service (certs, (localhost, 8080))
514505
]} *)
515506

516507
val impl :
517-
('cfg, 't, 'v) service ->
508+
('cfg, 't, 'v) t ->
518509
(module SERVICE
519510
with type configuration = 'cfg
520511
and type t = 't

0 commit comments

Comments
 (0)