Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
rrdd plugins: Added missing documentation.
Signed-off-by: Rok Strniša <rok.strnisa@citrix.com>
  • Loading branch information
Rok Strniša committed Jul 13, 2012
1 parent 071ef64 commit 7603f54
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ocaml/rrdd/rrdd_main.ml
Expand Up @@ -84,9 +84,9 @@ let start (xmlrpc_path, http_fwd_path) process =
accept_forever http_fwd_socket (fun this_connection ->
let msg_size = 16384 in
let buf = String.make msg_size '\000' in
debug "Calling Unixext.recv_fd()";
(* debug "Calling Unixext.recv_fd()"; *)
let len, _, received_fd = Unixext.recv_fd this_connection buf 0 msg_size [] in
debug "Unixext.recv_fd ok (len = %d)" len;
(* debug "Unixext.recv_fd ok (len = %d)" len; *)
finally
(fun _ ->
let req = String.sub buf 0 len |> Jsonrpc.of_string |> Http.Request.t_of_rpc in
Expand Down
6 changes: 6 additions & 0 deletions ocaml/rrdd/rrdd_server.ml
Expand Up @@ -484,27 +484,33 @@ module Plugin = struct
let list_of_rpc ~(rpc : Rpc.t) : Rpc.t list =
match rpc with Rpc.Enum l -> l | _ -> raise Invalid_payload

(* [assoc_opt ~key ~default l] gets string value associated with [key] in
* [l], returning [default] if no mapping is found. *)
let assoc_opt ~(key : string) ~(default : string)
(l : (string * Rpc.t) list) : string =
try Rpc.string_of_rpc (List.assoc key l) with
| Not_found -> default
| e -> error "Failed to obtain datasource key: %s" key; raise e

(* Converts string to the corresponding datasource type. *)
let ds_ty_of_string (s : string) : Rrd.ds_type =
match String.lowercase s with
| "absolute" -> Rrd.Gauge
| "rate" -> Rrd.Absolute
| "absolute_to_rate" -> Rrd.Derive
| _ -> raise Invalid_payload

(* Possible types for values in datasources. *)
type value_type = Float | Int64

(* Converts string to datasource value type. *)
let val_ty_of_string (s : string) : value_type =
match String.lowercase s with
| "float" -> Float
| "int64" -> Int64
| _ -> raise Invalid_payload

(* Converts an RPC value to a typed datasource value. *)
let ds_value_of_rpc ~(ty : value_type) ~(rpc : Rpc.t) : Rrd.ds_value_type =
match ty with
| Float -> Rrd.VT_Float (Rpc.float_of_rpc rpc)
Expand Down

0 comments on commit 7603f54

Please sign in to comment.