Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0.0 #311

Merged
merged 72 commits into from
Sep 29, 2020
Merged

3.0.0 #311

Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
ed9629d
Delete Travis Continuous Integration
dinosaure May 5, 2020
00f8338
Update GitHub Actions script
dinosaure May 5, 2020
9a698a2
Support ocamlformat
dinosaure May 5, 2020
417c8a2
Use dune 2.0
dinosaure May 5, 2020
37888a6
New implementation of conduit (core library)
dinosaure May 5, 2020
087e8e0
New implementation of conduit-tls which provides a composition mechan…
dinosaure May 5, 2020
50efb13
New implementation of conduit-lwt with mirage-flow implementation and…
dinosaure May 5, 2020
8dcb7df
New implementation of conduit-lwt-unix with Lwt's channel, tls and ss…
dinosaure May 5, 2020
8c44f50
New implementation of conduit-mirage with tcp/ip and tls layers
dinosaure May 5, 2020
1ce0f9a
New implementation of conduit-async with reader/writer helpers, tcp/i…
dinosaure May 5, 2020
402b68e
Add a ping-pong server to test conduit-{lwt-unix,async}
dinosaure May 5, 2020
4cc2bcb
Update OPAM files
dinosaure May 5, 2020
60ec59c
TCP linger used by conduit-lwt-unix is bigger (io_buffer_size)
dinosaure May 22, 2020
8ccfc86
Add interface helper for functoria/mirage about protocols impl.
dinosaure May 22, 2020
c5636a1
Add helper to easily register a resolver in mirage
dinosaure May 22, 2020
142fd9d
ocamlformat.0.14.2 pass
dinosaure May 26, 2020
7c09a83
Avoid to parse docstrings by ocamlformat
dinosaure Jun 4, 2020
fc38b9f
Integration of @samoht's simplication into the core library
dinosaure Jun 4, 2020
626c9b8
Update conduit-async with the new core
dinosaure Jun 4, 2020
bb4ee90
Update conduit-lwt with the new core
dinosaure Jun 4, 2020
ca12602
Update conduit-lwt-unix with the new core
dinosaure Jun 4, 2020
1fb8fc2
Update conduit-mirage with the new core
dinosaure Jun 4, 2020
66dbbc0
Update conduit-tls with the new core
dinosaure Jun 4, 2020
44125b6
Update tests with the new core
dinosaure Jun 4, 2020
c84a6b4
('a, 'b * 'c) service to ('a, 'b, 'c) service
dinosaure Jun 4, 2020
8b412ba
ocamlformat pass
dinosaure Jun 4, 2020
bd3af38
Rename End_of_input to End_of_flow
dinosaure Jun 4, 2020
1e89348
Add Conduit.Service.{accept,close}
dinosaure Jun 4, 2020
036a62d
ocamlformat pass
dinosaure Jun 4, 2020
aeaadfb
Remove prefix module name Client and add documentation
dinosaure Jun 8, 2020
1c36d32
Re-order documentation and ocamlformat pass
dinosaure Jun 8, 2020
8e75c74
Fix error about internal thd type and add a comment about it
dinosaure Jun 8, 2020
5401506
Add documentation
dinosaure Jun 9, 2020
96a9399
Rename connect to resolve and provide Conduit.connect as a simple cal…
dinosaure Jun 9, 2020
3a16024
Fallback API update to tests
dinosaure Jun 9, 2020
6748a1d
Fallback mirage-flow tests into conduit
dinosaure Jun 9, 2020
9143e28
ocamlformat pass
dinosaure Jun 9, 2020
94b2b97
Add tests about resolvers
dinosaure Jun 9, 2020
5843ee9
Add alcotest as a dependency to test core library
dinosaure Jun 9, 2020
44a3ce5
Functorize tests over LWT and ASYNC
dinosaure Jun 16, 2020
775cbf5
Delete conduit-lwt-unix and provide conduit-lwt-{ssl,tls} with lwt.unix
dinosaure Jun 20, 2020
aa9966a
Create new package conduit-async-{tls,ssl} and integrate conduit-asyn…
dinosaure Jun 22, 2020
7367a0b
Update GitHub Action with the new layout of conduit
dinosaure Jun 22, 2020
cfa3821
Optmize the core of conduit to have a smaller overhead about projection
dinosaure Jun 22, 2020
3f64382
Add a proper benchmark
dinosaure Jun 24, 2020
1f6936f
Add conduit-mirage.flow sub-package
dinosaure Jun 24, 2020
4215901
Add Conduit_lwt.io_of_flow
dinosaure Jun 24, 2020
e214f5e
Move librairies in their own directory
samoht Jun 29, 2020
a4a22fe
Minor naming cleanup
samoht Jun 29, 2020
96b789d
Simplify the code organisation for lwt and async libs
samoht Jun 29, 2020
7a8fc1e
Rename master -> service
samoht Jun 29, 2020
414f165
Refactor tests a bit
samoht Jun 29, 2020
a302c32
Remove `module type CONDUIT`
samoht Jun 29, 2020
f7613ac
Rename resolv_conf to resolve
samoht Jun 29, 2020
10e3d63
Be consistent when using Server/Service: try to use Service everywhere
samoht Jun 29, 2020
6fc534b
conduit-async-{tls,ssl} require conduit-async
dinosaure Jun 29, 2020
9779d77
Re-export resolvers type to signature
dinosaure Jul 10, 2020
ad082e7
Resolver from the DNS stack return a Mirage TCP endpoint
dinosaure Aug 14, 2020
9815aa0
Add mirage-time dependency into conduit-mirage
dinosaure Aug 26, 2020
a44d4d9
Add Service.equal to be able to prove the type of cfg/t/flow
dinosaure Aug 30, 2020
2f6912c
Extend the initialization of a Async TCP service
dinosaure Aug 30, 2020
9d83881
Add ?timeout option on the Conduit_*.serve function
dinosaure Aug 30, 2020
40e4330
Merge remote-tracking branch 'origin/master' into 3.0.0
dinosaure Sep 2, 2020
e25fce5
Apply dune build @fmt --auto-promote
dinosaure Sep 2, 2020
ee0fa7d
Fix compilation about the addition of ?timeout argument into Conduit_…
dinosaure Sep 2, 2020
9da9b21
Fix GitHub Action and handle only ubuntu
dinosaure Sep 2, 2020
4dffc53
Delay the initialisation of the server
dinosaure Sep 8, 2020
d975a1b
Add ke and bigstringaf as a dependency of conduit-mirage (@hannesm)
dinosaure Sep 10, 2020
6493c30
conduit-mirage requires at least dns-client.4.6.0
dinosaure Sep 10, 2020
056e94b
Refine dependencies of conduit-async packages (@anuragsoni)
dinosaure Sep 11, 2020
db46ef3
Use ocamlformat.0.15.0 now!
dinosaure Sep 29, 2020
5e0a0b4
Fix the documentation on the core library
dinosaure Sep 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,36 @@ jobs:
- uses: avsm/setup-ocaml@master
with:
ocaml-version: ${{ matrix.ocaml-version }}
- name: Install pkg-config
if: runner.os == 'macOS'
run: brew install pkg-config
- name: Deps
if: runner.os != 'Windows'
run: |
opam pin add -n conduit.dev .
opam pin add -n conduit-lwt.dev .
opam pin add -n conduit-lwt-unix.dev .
opam pin add -n conduit-async.dev .
opam pin add -n conduit-mirage.dev .
opam depext -y conduit conduit-lwt conduit-lwt-unix conduit-async conduit-mirage
opam install --deps-only .
opam pin add -n conduit-tls.dev .
opam depext -y conduit conduit-tls conduit-lwt conduit-lwt-unix conduit-async conduit-mirage
opam install --deps-only -t conduit conduit-tls conduit-lwt conduit-lwt-unix conduit-async conduit-mirage
- name: Deps (Windows)
if: runner.os == 'Windows'
run: |
opam pin add -n conduit.dev .
opam pin add -n conduit-lwt.dev .
opam pin add -n conduit-lwt-unix.dev .
opam pin add -n conduit-mirage.dev .
opam pin add -n conduit-tls.dev .
opam depext -y conduit conduit-tls conduit-lwt conduit-lwt-unix conduit-mirage
opam install --deps-only -t conduit conduit-tls conduit-lwt conduit-lwt-unix conduit-mirage
- name: Build (Windows)
if: runner.os == 'Windows'
run: opam exec -- dune build -p conduit,conduit-tls,conduit-lwt,conduit-lwt-unix,conduit-mirage
- name: Build
if: runner.os != 'Windows'
run: opam exec -- dune build
- name: Test
run: opam exec -- dune runtest
if: runner.os != 'Windows'
run: opam exec -- dune runtest --no-buffer --verbose -j 1
9 changes: 9 additions & 0 deletions .ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version = 0.14.2
break-infix = fit-or-vertical
parse-docstrings = true
indicate-multiline-delimiters=no
nested-match=align
sequence-style=separator
break-before-in=auto
if-then-else=keyword-first
parse-docstrings=false
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

103 changes: 80 additions & 23 deletions async/conduit_async.ml
Original file line number Diff line number Diff line change
@@ -1,23 +1,80 @@
(*
* Copyright (c) 2012-2017 Anil Madhavapeddy <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*)

module V1 = V1
module V2 = V2
module V3 = V3

[@@@deprecated "Use Conduit_async.V1"]
include V1.Conduit_async
module Async_scheduler = struct
type +'a t = 'a Async.Deferred.t

let bind x f = Async.Deferred.bind x ~f

let return x = Async.Deferred.return x
end

include Conduit.Make (Async_scheduler) (Cstruct) (Cstruct)

let failwith fmt = Format.kasprintf failwith fmt

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

let serve_with_handler :
type cfg master flow.
handler:(flow -> unit Async.Deferred.t) ->
service:(cfg, master, flow) Service.service ->
cfg ->
unit Async.Condition.t * unit Async.Deferred.t =
fun ~handler ~service cfg ->
let open Async in
let stop = Async.Condition.create () in
let module Svc = (val Service.impl service) in
let main =
Service.serve cfg ~service >>= function
| Error err -> failwith "%a" Service.pp_error err
| Ok master -> (
let rec loop () =
let close = Async.Condition.wait stop >>| fun () -> Ok `Stop in
let accept =
Svc.accept master >>? fun flow ->
Async.(Deferred.ok (return (`Flow flow))) in

Async.Deferred.any [ close; accept ] >>= function
| Ok (`Flow flow) ->
Async.don't_wait_for (handler flow) ;
Async.Scheduler.yield () >>= fun () -> (loop [@tailcall]) ()
| Ok `Stop -> Svc.close master
| Error err0 -> (
Svc.close master >>= function
| Ok () -> Async.return (Error err0)
| Error _err1 -> Async.return (Error err0)) in
loop () >>= function
| Ok () -> Async.return ()
| Error err -> failwith "%a" Svc.pp_error err) in
(stop, main)

let reader_and_writer_of_flow flow =
let open Async in
let recv flow writer =
let tmp = Cstruct.create 0x1000 in
let rec loop () =
Client.recv flow tmp >>= function
| Ok (`Input len) ->
Pipe.write writer (Cstruct.to_string (Cstruct.sub tmp 0 len)) >>= loop
| Ok `End_of_input ->
Pipe.close writer ;
Async.return ()
| Error err -> failwith "%a" Client.pp_error err in
loop () in
let send flow reader =
let rec loop () =
Pipe.read reader >>= function
| `Eof -> Async.return ()
| `Ok v ->
let rec go tmp =
if Cstruct.len tmp = 0
then Async.return ()
else
Client.send flow tmp >>= function
| Ok shift -> go (Cstruct.shift tmp shift)
| Error err -> failwith "%a" Client.pp_error err in
go (Cstruct.of_string v) >>= loop in
loop () in
let preader = Pipe.create_reader ~close_on_exception:true (recv flow) in
let pwriter = Pipe.create_writer (send flow) in
Reader.of_pipe (Core.Info.of_string "reader") preader >>= fun reader ->
Writer.of_pipe (Core.Info.of_string "writer") pwriter >>= fun (writer, _) ->
Async.return (reader, writer)
19 changes: 19 additions & 0 deletions async/conduit_async.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(** Conduit with Async. *)

module Async_scheduler :
Conduit.Sigs.SCHEDULER with type +'a t = 'a Async.Deferred.t

include
Conduit.S
with type input = Cstruct.t
and type output = Cstruct.t
and type +'a s = 'a Async.Deferred.t

val serve_with_handler :
handler:('flow -> unit Async.Deferred.t) ->
service:('cfg, 'master, 'flow) Service.service ->
'cfg ->
unit Async.Condition.t * unit Async.Deferred.t

val reader_and_writer_of_flow :
Client.flow -> (Async.Reader.t * Async.Writer.t) Async.Deferred.t
Loading