package catapult

  1. Overview
  2. Docs
Tracing system based on the Catapult/TEF format

Install

Dune Dependency

Authors

Maintainers

Sources

v0.1.tar.gz
md5=a7bfa27c3ddd2d29c27173de09293149
sha512=49766ea38c57734918debd6218d95c62f11eb12a6fd3ef5f6a2c60344cea7c274436a46fab1e48abbe0d3f125f31705d2005ab7cae9e56d5f41778c1d2943d65

doc/src/catapult/endpoint_address.ml.html

Source file endpoint_address.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

type t =
  | Unix of string
  | Tcp of string * int

let to_string = function
  | Unix s -> Printf.sprintf "ipc://%s" s
  | Tcp (addr,port) -> Printf.sprintf "tcp://%s:%d" addr port

let str_prefix ~pre s =
  let len = String.length pre in
  if len > String.length s then false
  else (
    let rec check i =
      if i=len then true
      else if Stdlib.(<>) (String.unsafe_get s i) (String.unsafe_get pre i) then false
      else check (i+1)
    in
    check 0
  )

let of_string_exn s =
  if str_prefix ~pre:"tcp://" s then (
    let s = String.sub s 6 (String.length s-6) in
    match String.index_opt s ':' with
    | Some i ->
      let s1 = String.sub s 0 i in
      let p =
        try int_of_string (String.sub s (i+1) (String.length s-i-1))
        with _ -> invalid_arg "endpoint addr: invalid port" in
      Tcp (s1,p)
    | None -> invalid_arg "endpoint addr: invalid tcp address"
  ) else if str_prefix ~pre:"ipc://" s then (
    let s = String.sub s 6 (String.length s-6) in
    Unix s
  ) else (
    invalid_arg "endpoint addr: invalid address (expect tcp:// or ipc://)"
  )

let of_string s = try Some (of_string_exn s) with _ -> None

let default = Tcp ("127.0.0.1", 6981)
OCaml

Innovation. Community. Security.