Skip to content

eio backend, second attempt #95

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
allow-prerelease-opam: true

- name: Deps
run: opam install odig tiny_httpd tiny_httpd_camlzip
run: opam install odig tiny_httpd tiny_httpd_camlzip tiny_httpd_eio

- name: Build
run: opam exec -- odig odoc --cache-dir=_doc/ tiny_httpd tiny_httpd_camlzip
run: opam exec -- odig odoc --cache-dir=_doc/ tiny_httpd tiny_httpd_camlzip tiny_httpd_eio

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

- run: opam install ./tiny_httpd.opam ./tiny_httpd_camlzip.opam --deps-only --with-test

- run: opam exec -- dune build @install -p tiny_httpd,tiny_httpd_camlzip
- run: opam exec -- dune build @install -p tiny_httpd,tiny_httpd_camlzip,tiny_httpd_eio

- run: opam exec -- dune build @src/runtest @examples/runtest @tests/runtest -p tiny_httpd
if: ${{ matrix.os == 'ubuntu-latest' }}
Expand All @@ -50,4 +50,4 @@ jobs:

- run: opam install logs magic-mime -y

- run: opam exec -- dune build @install -p tiny_httpd,tiny_httpd_camlzip
- run: opam exec -- dune build @install -p tiny_httpd,tiny_httpd_camlzip,tiny_httpd_eio
9 changes: 9 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,12 @@
(iostream-camlzip (>= 0.2.1))
(logs :with-test)
(odoc :with-doc)))

(package
(name tiny_httpd_eio)
(synopsis "Use eio for tiny_httpd")
(depends
(tiny_httpd (= :version))
(eio (and (>= 1.0) (< 2.0)))
(logs :with-test)
(odoc :with-doc)))
2 changes: 2 additions & 0 deletions echo_eio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec dune exec --display=quiet --profile=release "examples/echo_eio.exe" -- $@
31 changes: 29 additions & 2 deletions examples/dune
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,29 @@
(executable
(name echo)
(flags :standard -warn-error -a+8)
(modules echo vfs)
(libraries tiny_httpd logs tiny_httpd_camlzip tiny_httpd.multipart-form-data))
(modules echo)
(libraries
tiny_httpd
logs
echo_vfs
tiny_httpd_camlzip
tiny_httpd.multipart-form-data))

(executable
(name echo_eio)
(flags :standard -warn-error -a+8)
(modules echo_eio)
(libraries
tiny_httpd
tiny_httpd_eio
eio
eio_main
logs
echo_vfs
trace.core
trace-tef
tiny_httpd_camlzip
tiny_httpd.multipart-form-data))

(executable
(name writer)
Expand Down Expand Up @@ -51,6 +72,12 @@

; produce an embedded FS

(library
(name echo_vfs)
(modules vfs)
(wrapped false)
(libraries tiny_httpd))

(rule
(targets vfs.ml)
(deps
Expand Down
6 changes: 4 additions & 2 deletions examples/echo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,14 @@ let () =
"-p", Arg.Set_int port_, " set port";
"--debug", Arg.Unit setup_logging, " enable debug";
"-j", Arg.Set_int j, " maximum number of connections";
"--addr", Arg.Set_string addr, " binding address";
"--addr", Arg.Set_string addr, " binding address";
])
(fun _ -> raise (Arg.Bad ""))
"echo [option]*";

let server = Tiny_httpd.create ~addr:!addr ~port:!port_ ~max_connections:!j () in
let server =
Tiny_httpd.create ~addr:!addr ~port:!port_ ~max_connections:!j ()
in

Tiny_httpd_camlzip.setup ~compress_above:1024 ~buf_size:(16 * 1024) server;
let m_stats, get_stats = middleware_stat () in
Expand Down
Loading
Loading