wip: ezcurl

This commit is contained in:
Simon Cruanes 2025-02-15 20:38:03 -05:00
parent fe57c8082e
commit fc7559db1f
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
7 changed files with 81 additions and 1 deletions

View file

@ -37,4 +37,15 @@
(tiny_httpd (>= 0.17))) (tiny_httpd (>= 0.17)))
(tags (nanoev http))) (tags (nanoev http)))
(package
(name nanoev_ezcurl)
(synopsis "Use nanoev as a basis for ezcurl")
(depends
ocaml
dune
nanoev
picos
(ezcurl (>= 0.2.4)))
(tags (nanoev http curl)))
; See the complete stanza docs at https://dune.readthedocs.io/en/stable/reference/dune-project/index.html ; See the complete stanza docs at https://dune.readthedocs.io/en/stable/reference/dune-project/index.html

View file

@ -1,6 +1,6 @@
# This file is generated by dune, edit dune-project instead # This file is generated by dune, edit dune-project instead
opam-version: "2.0" opam-version: "2.0"
synopsis: "Tiny event loop around `select`" synopsis: "Tiny event loop abstraction"
maintainer: ["Simon Cruanes"] maintainer: ["Simon Cruanes"]
authors: ["Simon Cruanes"] authors: ["Simon Cruanes"]
license: "MIT" license: "MIT"

32
nanoev_ezcurl.opam Normal file
View file

@ -0,0 +1,32 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
synopsis: "Use nanoev as a basis for ezcurl"
maintainer: ["Simon Cruanes"]
authors: ["Simon Cruanes"]
license: "MIT"
tags: ["nanoev" "http" "curl"]
homepage: "https://github.com/c-cube/nanoev"
bug-reports: "https://github.com/c-cube/nanoev/issues"
depends: [
"ocaml"
"dune" {>= "2.7"}
"nanoev"
"picos"
"ezcurl" {>= "0.2.4"}
"odoc" {with-doc}
]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/c-cube/nanoev.git"

View file

@ -4,6 +4,7 @@ synopsis: "Use nanoev as a basis for tiny_httpd"
maintainer: ["Simon Cruanes"] maintainer: ["Simon Cruanes"]
authors: ["Simon Cruanes"] authors: ["Simon Cruanes"]
license: "MIT" license: "MIT"
tags: ["nanoev" "http"]
homepage: "https://github.com/c-cube/nanoev" homepage: "https://github.com/c-cube/nanoev"
bug-reports: "https://github.com/c-cube/nanoev/issues" bug-reports: "https://github.com/c-cube/nanoev/issues"
depends: [ depends: [

9
src/ezcurl/dune Normal file
View file

@ -0,0 +1,9 @@
(library
(name nanoev_ezcurl)
(public_name nanoev_ezcurl)
(libraries
threads
picos
(re_export nanoev)
nanoev.picos
(re_export ezcurl)))

View file

@ -0,0 +1,22 @@
module EV = Nanoev_picos
include Ezcurl_core
open struct
(* TODO: have a thread-local multi handle? *)
let multi : Curl.Multi.mt option Atomic.t = Atomic.make None
let lock = Mutex.create ()
let get_mt () =
match Atomic.get multi with
| Some mt -> mt
end
include Ezcurl_core.Make (struct
type 'a t = 'a
let[@inline] return x = x
let fail = raise
let ( >>= ) = ( |> )
let ( >|= ) = ( |> )
let perform (client : Curl.t) : Curl.curlCode = Curl.Multi.p
end)

View file

@ -0,0 +1,5 @@
include module type of struct
include Ezcurl_core
end
include Ezcurl_core.S with type 'a io := 'a