Skip to content

Commit a07936d

Browse files
authored
eio backend, second attempt (#95)
feat: `tiny_httpd_eio` library provides a tiny_httpd server that relies on Eio for non-blocking sockets and for concurrency using eio fibers.
1 parent ba19880 commit a07936d

16 files changed

Lines changed: 794 additions & 51 deletions

File tree

.github/workflows/format.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
branches:
77
- main
88

9+
jobs:
910
format:
1011
name: format
1112
strategy:

.github/workflows/gh-pages.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@ jobs:
3838

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

41-
- run: opam exec -- dune build @install -p tiny_httpd,tiny_httpd_camlzip
41+
- name: Build (OCaml 4.x)
42+
run: opam exec -- dune build @install -p tiny_httpd,tiny_httpd_camlzip
43+
if: ${{ !startsWith(matrix.ocaml-compiler, '5.') }}
44+
45+
- name: Build (OCaml 5.x, includes eio)
46+
run: |
47+
opam install ./tiny_httpd.opam ./tiny_httpd_eio.opam --deps-only --with-test
48+
opam exec -- dune build @install -p tiny_httpd,tiny_httpd_camlzip,tiny_httpd_eio
49+
if: ${{ startsWith(matrix.ocaml-compiler, '5.') }}
4250

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

5159
- run: opam install logs magic-mime -y
5260

53-
- run: opam exec -- dune build @install -p tiny_httpd,tiny_httpd_camlzip
61+
- name: Final build (OCaml 4.x)
62+
run: opam exec -- dune build @install -p tiny_httpd,tiny_httpd_camlzip
63+
if: ${{ !startsWith(matrix.ocaml-compiler, '5.') }}
64+
65+
- name: Final build (OCaml 5.x, includes eio)
66+
run: opam exec -- dune build @install -p tiny_httpd,tiny_httpd_camlzip,tiny_httpd_eio
67+
if: ${{ startsWith(matrix.ocaml-compiler, '5.') }}

dune-project

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
(logs :with-test)
2929
(conf-libcurl :with-test)
3030
(ptime :with-test)
31-
(qcheck-core (and (>= 0.9) :with-test))))
31+
(qcheck-core (and (>= 0.91) :with-test))))
3232

3333
(package
3434
(name tiny_httpd_camlzip)
@@ -39,3 +39,13 @@
3939
(iostream-camlzip (>= 0.2.1))
4040
(logs :with-test)
4141
(odoc :with-doc)))
42+
43+
(package
44+
(name tiny_httpd_eio)
45+
(synopsis "Use eio for tiny_httpd")
46+
(depends
47+
(tiny_httpd (= :version))
48+
(eio (and (>= 1.0) (< 2.0)))
49+
base-unix
50+
(logs :with-test)
51+
(odoc :with-doc)))

echo_eio.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
exec dune exec --display=quiet --profile=release "examples/echo_eio.exe" -- $@

examples/dune

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,27 @@
1111
(executable
1212
(name echo)
1313
(flags :standard -warn-error -a+8)
14-
(modules echo vfs)
14+
(modules echo)
1515
(libraries
1616
tiny_httpd
1717
logs
18+
echo_vfs
19+
tiny_httpd_camlzip
20+
tiny_httpd.multipart-form-data))
21+
22+
(executable
23+
(name echo_eio)
24+
(flags :standard -warn-error -a+8)
25+
(modules echo_eio)
26+
(libraries
27+
tiny_httpd
28+
tiny_httpd_eio
29+
eio
30+
eio_main
31+
logs
32+
echo_vfs
33+
trace.core
34+
trace-tef
1835
tiny_httpd_camlzip
1936
tiny_httpd.multipart-form-data))
2037

@@ -55,6 +72,12 @@
5572

5673
; produce an embedded FS
5774

75+
(library
76+
(name echo_vfs)
77+
(modules vfs)
78+
(wrapped false)
79+
(libraries tiny_httpd))
80+
5881
(rule
5982
(targets vfs.ml)
6083
(deps

0 commit comments

Comments
 (0)