From 65a96f6412c8f3fd9fe18ca15f2e9c8e191ec2a8 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Mon, 10 Dec 2018 22:09:24 +0000 Subject: [PATCH 1/4] Switch to Dune --- async/dune | 7 +++++++ async/jbuild | 9 --------- benchmarks/dune | 10 ++++++++++ benchmarks/jbuild | 11 ----------- benchmarks/wrk_async_benchmark.ml | 2 +- benchmarks/wrk_lwt_benchmark.ml | 2 +- dune-project | 1 + examples/async/async_echo_post.ml | 4 ++-- examples/async/dune | 5 +++++ examples/async/jbuild | 4 ---- examples/lwt/dune | 3 +++ examples/lwt/jbuild | 5 ----- httpaf-async.opam | 8 ++++---- httpaf-lwt.opam | 6 +++--- httpaf.opam | 8 ++++---- httpaf_mirage.mli | 23 +++++++++++++++++++++++ lib/dune | 6 ++++++ lib/jbuild | 8 -------- lib_test/dune | 22 ++++++++++++++++++++++ lib_test/jbuild | 24 ------------------------ lwt/dune | 5 +++++ lwt/jbuild | 7 ------- 22 files changed, 97 insertions(+), 83 deletions(-) create mode 100644 async/dune delete mode 100644 async/jbuild create mode 100644 benchmarks/dune delete mode 100644 benchmarks/jbuild create mode 100644 dune-project create mode 100644 examples/async/dune delete mode 100644 examples/async/jbuild create mode 100644 examples/lwt/dune delete mode 100644 examples/lwt/jbuild create mode 100644 httpaf_mirage.mli create mode 100644 lib/dune delete mode 100644 lib/jbuild create mode 100644 lib_test/dune delete mode 100644 lib_test/jbuild create mode 100644 lwt/dune delete mode 100644 lwt/jbuild diff --git a/async/dune b/async/dune new file mode 100644 index 00000000..411e6ed7 --- /dev/null +++ b/async/dune @@ -0,0 +1,7 @@ +(library + (name httpaf_async) + (public_name httpaf-async) + (wrapped false) + (libraries + async core angstrom-async faraday-async httpaf) + (flags (:standard -safe-string))) diff --git a/async/jbuild b/async/jbuild deleted file mode 100644 index a8903689..00000000 --- a/async/jbuild +++ /dev/null @@ -1,9 +0,0 @@ -(jbuild_version 1) - -(library - ((name httpaf_async) - (public_name httpaf-async) - (wrapped false) - (libraries - (async core angstrom-async faraday-async httpaf)) - (flags (:standard -safe-string)))) diff --git a/benchmarks/dune b/benchmarks/dune new file mode 100644 index 00000000..b6d08d02 --- /dev/null +++ b/benchmarks/dune @@ -0,0 +1,10 @@ +(executable + (libraries httpaf httpaf-async async core) + (modules wrk_async_benchmark) + (name wrk_async_benchmark) + (flags (:standard -w -9))) + +(executable + (name wrk_lwt_benchmark) + (modules Wrk_lwt_benchmark) + (libraries httpaf httpaf-lwt lwt.unix)) diff --git a/benchmarks/jbuild b/benchmarks/jbuild deleted file mode 100644 index 87b0897b..00000000 --- a/benchmarks/jbuild +++ /dev/null @@ -1,11 +0,0 @@ -(jbuild_version 1) - -(executable - ((libraries (httpaf httpaf-async async core)) - (modules (wrk_async_benchmark)) - (name wrk_async_benchmark))) - -(executable - ((name wrk_lwt_benchmark) - (modules (Wrk_lwt_benchmark)) - (libraries (httpaf httpaf-lwt lwt.unix)))) diff --git a/benchmarks/wrk_async_benchmark.ml b/benchmarks/wrk_async_benchmark.ml index 7c4043f2..784168a6 100644 --- a/benchmarks/wrk_async_benchmark.ml +++ b/benchmarks/wrk_async_benchmark.ml @@ -8,7 +8,7 @@ let text = "CHAPTER I. Down the Rabbit-Hole Alice was beginning to get very tir let text = Bigstring.of_string text let headers = Headers.of_list ["content-length", string_of_int (Bigstring.length text)] -let error_handler _ ?request error start_response = +let error_handler _ ?request:_ error start_response = let response_body = start_response Headers.empty in begin match error with | `Exn exn -> diff --git a/benchmarks/wrk_lwt_benchmark.ml b/benchmarks/wrk_lwt_benchmark.ml index e19be227..e5a96cf3 100644 --- a/benchmarks/wrk_lwt_benchmark.ml +++ b/benchmarks/wrk_lwt_benchmark.ml @@ -56,7 +56,7 @@ let connection_handler = reqd (Response.create `Not_found) "Route not found" in - let error_handler _ ?request error start_response = + let error_handler _ ?request:_ error start_response = let response_body = start_response Headers.empty in begin match error with diff --git a/dune-project b/dune-project new file mode 100644 index 00000000..81c449d2 --- /dev/null +++ b/dune-project @@ -0,0 +1 @@ +(lang dune 1.5) diff --git a/examples/async/async_echo_post.ml b/examples/async/async_echo_post.ml index 31ec4519..099ffde7 100644 --- a/examples/async/async_echo_post.ml +++ b/examples/async/async_echo_post.ml @@ -5,7 +5,7 @@ open Httpaf open Httpaf_async -let error_handler _ ?request error start_response = +let error_handler _ ?request:_ error start_response = let response_body = start_response Headers.empty in begin match error with | `Exn exn -> @@ -46,7 +46,7 @@ let main port max_accepts_per_batch () = Tcp.(Server.create_sock ~on_handler_error:`Raise ~backlog:10_000 ~max_connections:10_000 ~max_accepts_per_batch where_to_listen) (Server.create_connection_handler ~request_handler ~error_handler) - >>= fun server -> + >>= fun _server -> Deferred.never () let () = diff --git a/examples/async/dune b/examples/async/dune new file mode 100644 index 00000000..465e7fed --- /dev/null +++ b/examples/async/dune @@ -0,0 +1,5 @@ +(executables + (libraries httpaf httpaf-async async core) + (modules async_echo_post async_get async_post) + (names async_echo_post async_get async_post) + (flags (:standard -w -9))) diff --git a/examples/async/jbuild b/examples/async/jbuild deleted file mode 100644 index 0028c1fc..00000000 --- a/examples/async/jbuild +++ /dev/null @@ -1,4 +0,0 @@ -(executables - ((libraries (httpaf httpaf-async async core)) - (modules (async_echo_post async_get async_post)) - (names (async_echo_post async_get async_post)))) diff --git a/examples/lwt/dune b/examples/lwt/dune new file mode 100644 index 00000000..e90ca77c --- /dev/null +++ b/examples/lwt/dune @@ -0,0 +1,3 @@ +(executables + (names lwt_get lwt_post lwt_echo_server) + (libraries httpaf httpaf-lwt lwt lwt.unix)) diff --git a/examples/lwt/jbuild b/examples/lwt/jbuild deleted file mode 100644 index b21fe052..00000000 --- a/examples/lwt/jbuild +++ /dev/null @@ -1,5 +0,0 @@ -(jbuild_version 1) - -(executables - ((names (lwt_get lwt_post lwt_echo_server)) - (libraries (httpaf httpaf-lwt lwt lwt.unix)))) diff --git a/httpaf-async.opam b/httpaf-async.opam index 04e77a6b..05601ebd 100644 --- a/httpaf-async.opam +++ b/httpaf-async.opam @@ -7,13 +7,13 @@ homepage: "https://github.com/inhabitedtype/httpaf" bug-reports: "https://github.com/inhabitedtype/httpaf/issues" dev-repo: "git+https://github.com/inhabitedtype/httpaf.git" build: [ - ["jbuilder" "subst" "-p" name] {pinned} - ["jbuilder" "build" "-p" name "-j" jobs] - ["jbuilder" "runtest" "-p" name] {with-test} + ["dune" "subst" "-p" name] {pinned} + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name] {with-test} ] depends: [ "ocaml" {>= "4.03.0"} - "jbuilder" {build & >= "1.0+beta10"} + "dune" {build} "angstrom-async" {>= "0.9.0"} "faraday-async" "async" diff --git a/httpaf-lwt.opam b/httpaf-lwt.opam index 1c47a2c9..76267e7a 100644 --- a/httpaf-lwt.opam +++ b/httpaf-lwt.opam @@ -7,14 +7,14 @@ homepage: "https://github.com/inhabitedtype/httpaf" bug-reports: "https://github.com/inhabitedtype/httpaf/issues" dev-repo: "git+https://github.com/inhabitedtype/httpaf.git" build: [ - ["jbuilder" "subst" "-p" name] {pinned} - ["jbuilder" "build" "-p" name "-j" jobs] + ["dune" "subst" "-p" name] {pinned} + ["dune" "build" "-p" name "-j" jobs] ] depends: [ "ocaml" {>= "4.03.0"} "faraday-lwt-unix" "httpaf" - "jbuilder" {build & >= "1.0+beta10"} + "dune" {build} "lwt" ] synopsis: "Lwt support for http/af" diff --git a/httpaf.opam b/httpaf.opam index d4ae80a7..6263f72d 100644 --- a/httpaf.opam +++ b/httpaf.opam @@ -6,13 +6,13 @@ homepage: "https://github.com/inhabitedtype/httpaf" bug-reports: "https://github.com/inhabitedtype/httpaf/issues" dev-repo: "git+https://github.com/inhabitedtype/httpaf.git" build: [ - ["jbuilder" "subst" "-p" name] {pinned} - ["jbuilder" "build" "-p" name "-j" jobs] - ["jbuilder" "runtest" "-p" name] {with-test} + ["dune" "subst" "-p" name] {pinned} + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name] {with-test} ] depends: [ "ocaml" {>= "4.03.0"} - "jbuilder" {build & >= "1.0+beta10"} + "dune" {build} "alcotest" {with-test} "angstrom" {>= "0.9.0"} "faraday" {>= "0.5.0"} diff --git a/httpaf_mirage.mli b/httpaf_mirage.mli new file mode 100644 index 00000000..63fe2a5a --- /dev/null +++ b/httpaf_mirage.mli @@ -0,0 +1,23 @@ +(* The function that results from [create_connection_handler] should be passed + to [Lwt_io.establish_server_with_client_socket]. For an example, see + [examples/lwt_echo_server.ml]. *) +module Server : sig + type request_handler = + Lwt_unix.file_descr Httpaf.Server_connection.request_handler + + val create_connection_handler + : ?config : Httpaf.Server_connection.Config.t + -> request_handler : (Unix.sockaddr -> request_handler) + -> error_handler : (Unix.sockaddr -> Httpaf.Server_connection.error_handler) + -> (Unix.sockaddr -> Lwt_unix.file_descr -> unit Lwt.t) +end + +(* For an example, see [examples/lwt_get.ml]. *) +module Client : sig + val request + : Lwt_unix.file_descr + -> Httpaf.Request.t + -> error_handler : Httpaf.Client_connection.error_handler + -> response_handler : Httpaf.Client_connection.response_handler + -> [`write] Httpaf.Body.t +end diff --git a/lib/dune b/lib/dune new file mode 100644 index 00000000..fdcd49f5 --- /dev/null +++ b/lib/dune @@ -0,0 +1,6 @@ +(library + (name httpaf) + (public_name httpaf) + (libraries + angstrom faraday bigstringaf result) + (flags (:standard -safe-string))) diff --git a/lib/jbuild b/lib/jbuild deleted file mode 100644 index 17e97851..00000000 --- a/lib/jbuild +++ /dev/null @@ -1,8 +0,0 @@ -(jbuild_version 1) - -(library - ((name httpaf) - (public_name httpaf) - (libraries - (angstrom faraday bigstringaf result)) - (flags (:standard -safe-string)))) diff --git a/lib_test/dune b/lib_test/dune new file mode 100644 index 00000000..2735bcb2 --- /dev/null +++ b/lib_test/dune @@ -0,0 +1,22 @@ +(executables + (libraries bigstringaf httpaf alcotest) + (modules test_httpaf test_httpaf_server test_httpaf_client simulator) + (names test_httpaf test_httpaf_server test_httpaf_client)) + +(alias + (name runtest) + (package httpaf) + (deps test_httpaf.exe) + (action (run %{deps}))) + +(alias + (name runtest) + (package httpaf) + (deps test_httpaf_server.exe) + (action (run %{deps}))) + +(alias + (name runtest) + (package httpaf) + (deps test_httpaf_client.exe) + (action (run %{deps}))) diff --git a/lib_test/jbuild b/lib_test/jbuild deleted file mode 100644 index dfce1d32..00000000 --- a/lib_test/jbuild +++ /dev/null @@ -1,24 +0,0 @@ -(jbuild_version 1) - -(executables - ((libraries (bigstringaf httpaf alcotest)) - (modules (test_httpaf test_httpaf_server test_httpaf_client simulator)) - (names (test_httpaf test_httpaf_server test_httpaf_client)))) - -(alias - ((name runtest) - (package httpaf) - (deps (test_httpaf.exe)) - (action (run ${<})))) - -(alias - ((name runtest) - (package httpaf) - (deps (test_httpaf_server.exe)) - (action (run ${<})))) - -(alias - ((name runtest) - (package httpaf) - (deps (test_httpaf_client.exe)) - (action (run ${<})))) diff --git a/lwt/dune b/lwt/dune new file mode 100644 index 00000000..47a2c7c7 --- /dev/null +++ b/lwt/dune @@ -0,0 +1,5 @@ +(library + (name httpaf_lwt) + (public_name httpaf-lwt) + (libraries faraday-lwt-unix httpaf lwt.unix) + (flags (:standard -safe-string))) diff --git a/lwt/jbuild b/lwt/jbuild deleted file mode 100644 index 179e7f9a..00000000 --- a/lwt/jbuild +++ /dev/null @@ -1,7 +0,0 @@ -(jbuild_version 1) - -(library - ((name httpaf_lwt) - (public_name httpaf-lwt) - (libraries (faraday-lwt-unix httpaf lwt.unix)) - (flags (:standard -safe-string)))) From 72662201a2b056b428d9ba4971ec0ff30ec12421 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Mon, 10 Dec 2018 22:32:41 +0000 Subject: [PATCH 2/4] fix subst --- dune-project | 2 ++ httpaf-async.opam | 2 +- httpaf-lwt.opam | 2 +- httpaf.opam | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dune-project b/dune-project index 81c449d2..799bf5a3 100644 --- a/dune-project +++ b/dune-project @@ -1 +1,3 @@ (lang dune 1.5) + +(name httpaf) diff --git a/httpaf-async.opam b/httpaf-async.opam index 05601ebd..af6a885b 100644 --- a/httpaf-async.opam +++ b/httpaf-async.opam @@ -7,7 +7,7 @@ homepage: "https://github.com/inhabitedtype/httpaf" bug-reports: "https://github.com/inhabitedtype/httpaf/issues" dev-repo: "git+https://github.com/inhabitedtype/httpaf.git" build: [ - ["dune" "subst" "-p" name] {pinned} + ["dune" "subst"] {pinned} ["dune" "build" "-p" name "-j" jobs] ["dune" "runtest" "-p" name] {with-test} ] diff --git a/httpaf-lwt.opam b/httpaf-lwt.opam index 76267e7a..e28c52e0 100644 --- a/httpaf-lwt.opam +++ b/httpaf-lwt.opam @@ -7,7 +7,7 @@ homepage: "https://github.com/inhabitedtype/httpaf" bug-reports: "https://github.com/inhabitedtype/httpaf/issues" dev-repo: "git+https://github.com/inhabitedtype/httpaf.git" build: [ - ["dune" "subst" "-p" name] {pinned} + ["dune" "subst"] {pinned} ["dune" "build" "-p" name "-j" jobs] ] depends: [ diff --git a/httpaf.opam b/httpaf.opam index 6263f72d..623acd94 100644 --- a/httpaf.opam +++ b/httpaf.opam @@ -6,7 +6,7 @@ homepage: "https://github.com/inhabitedtype/httpaf" bug-reports: "https://github.com/inhabitedtype/httpaf/issues" dev-repo: "git+https://github.com/inhabitedtype/httpaf.git" build: [ - ["dune" "subst" "-p" name] {pinned} + ["dune" "subst"] {pinned} ["dune" "build" "-p" name "-j" jobs] ["dune" "runtest" "-p" name] {with-test} ] From 7b5bdea199d31161375ad151fa668ec24790df6a Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sat, 12 Jan 2019 14:05:03 +0000 Subject: [PATCH 3/4] Remove mirage bits --- httpaf_mirage.mli | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 httpaf_mirage.mli diff --git a/httpaf_mirage.mli b/httpaf_mirage.mli deleted file mode 100644 index 63fe2a5a..00000000 --- a/httpaf_mirage.mli +++ /dev/null @@ -1,23 +0,0 @@ -(* The function that results from [create_connection_handler] should be passed - to [Lwt_io.establish_server_with_client_socket]. For an example, see - [examples/lwt_echo_server.ml]. *) -module Server : sig - type request_handler = - Lwt_unix.file_descr Httpaf.Server_connection.request_handler - - val create_connection_handler - : ?config : Httpaf.Server_connection.Config.t - -> request_handler : (Unix.sockaddr -> request_handler) - -> error_handler : (Unix.sockaddr -> Httpaf.Server_connection.error_handler) - -> (Unix.sockaddr -> Lwt_unix.file_descr -> unit Lwt.t) -end - -(* For an example, see [examples/lwt_get.ml]. *) -module Client : sig - val request - : Lwt_unix.file_descr - -> Httpaf.Request.t - -> error_handler : Httpaf.Client_connection.error_handler - -> response_handler : Httpaf.Client_connection.response_handler - -> [`write] Httpaf.Body.t -end From 4d32c6e1e2d53b6869fe62d637b0b8ec3c738685 Mon Sep 17 00:00:00 2001 From: Doug Patti Date: Sun, 13 Jan 2019 16:22:34 -0500 Subject: [PATCH 4/4] update references to jbuilder in Makefile and README --- Makefile | 8 ++++---- README.md | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index a1213572..0f459184 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,18 @@ .PHONY: all build clean test build: - jbuilder build --dev @install + dune build @install all: build test: - jbuilder runtest --dev + dune runtest install: - jbuilder install + dune install uninstall: - jbuilder uninstall + dune uninstall clean: rm -rf _build *.install diff --git a/README.md b/README.md index 40d96cb0..9476e058 100644 --- a/README.md +++ b/README.md @@ -62,10 +62,10 @@ opam install --deps-only httpaf After this, you may install a development version of the library using the install command as usual. -Tests can be run via jbuilder: +Tests can be run via dune: ```bash -jbuilder runtest +dune runtest ``` ## License