package webmachine

  1. Overview
  2. Docs
A REST toolkit for OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

0.6.2.tar.gz
sha256=d6e6567c1e177aefe6f1a62a32ff61942521866ee1579a55ffb2b7970ddc04c4
md5=e49e81e81ac0527e452aa6f6fd5c9616

doc/webmachine/Webmachine/module-type-CLOCK/index.html

Module type Webmachine.CLOCKSource

The CLOCK module signature defines a clock source, that is used with the Webmachine.Make(IO)(Clock) functor.

Examples:

(* static mock time *) module MockClock = struct let now = fun () -> 1526322704 end

(* using Unix.gettimeofday *) module UnixClock = struct let now = fun () -> int_of_float (Unix.gettimeofday ()) end

(* using Ptime_clock, which uses the system POSIX clock/gettimeofday *) module PtimeClock = struct let now = fun () -> int_of_float (Ptime.to_float (Ptime_clock.now ())) end

(* using mirage-clock in MirageOS unikernels *) module MirageClock = struct let now = fun () -> let d, ps = Pclock.now_d_ps clock in let days_in_seconds = d * 86_400 in let picos_in_seconds = Int64.(to_int (div ps (1_000_000_000_000L))) i days_in_seconds + picos_in_seconds end

Sourceval now : unit -> int
OCaml

Innovation. Community. Security.