Skip to content

Commit

Permalink
eio: add dns_client_eio.mli
Browse files Browse the repository at this point in the history
  • Loading branch information
bikallem committed Jun 23, 2022
1 parent 5880efc commit aa9de1a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
19 changes: 12 additions & 7 deletions eio/client/dns_client_eio.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,33 @@ type env = <
secure_random : Eio.Flow.source;
>

type io_addr = Ipaddr.t * int
type stack = env * E.Switch.t

module Transport : Dns_client.S
with type io_addr = Ipaddr.t * int
and type stack = (env * E.Switch.t)
with type io_addr = io_addr
and type stack = stack
and type +'a io = 'a
= struct
type io_addr = Ipaddr.t * int
type stack = (env * E.Switch.t)
type nonrec io_addr = io_addr
type nonrec stack = stack
type +'a io = 'a
type context = E.Net.stream_socket

type nameservers =
| Static of io_addr Queue.t
| Resolv_conf of {
mutable nameservers : io_addr Queue.t ;
mutable digest : Digest.t option ;
}

type t = {
nameservers : nameservers ;
timeout_ns : int64 ; (* Timeout in nano seconds *)
env : env;
sw : E.Switch.t ;
mutex : E.Mutex.t ;
}
type context = E.Net.stream_socket

let read_file env file =
match E.Dir.load (E.Stdenv.fs env) file with
Expand Down Expand Up @@ -186,8 +191,8 @@ module Transport : Dns_client.S
end

module Client = Dns_client.Make(Transport)
module type Client_intf = module type of Dns_client.Make(Transport)
module type DNS_CLIENT = module type of Dns_client.Make(Transport)

let run ?sleep env (f:(module Client_intf) -> 'a) =
let run ?sleep env (f:(module DNS_CLIENT) -> 'a) =
Mirage_crypto_rng_eio.run ?sleep env @@ fun () ->
f (module Client)
15 changes: 15 additions & 0 deletions eio/client/dns_client_eio.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
type env = <
clock : Eio.Time.clock ;
net : Eio.Net.t ;
fs : Eio.Dir.t ;
secure_random : Eio.Flow.source;
>

module Transport : Dns_client.S
with type io_addr = Ipaddr.t * int
and type stack = env * Eio.Switch.t
and type +'a io = 'a

module type DNS_CLIENT = module type of Dns_client.Make(Transport)

val run : ?sleep:int64 -> < env; ..> -> ((module DNS_CLIENT) -> 'a) -> 'a

0 comments on commit aa9de1a

Please sign in to comment.