[ANN] First release of corosync

Aug 2024 - I am happy to announce the release of opam - corosync, a binding to libcorosync. It is not (yet) a complete binding to all the APIs of libcorosync, but the bindings to the following libraries are implemented:

  1. libcmap (in memory stats and config database)
  2. libquorum and libvotequorum (query of quorum states)
  3. libcfg (config reload, etc)
  4. libcpg (closed process group, corosync’s model of a cluster)

This project lives on GitHub - Vincent-lau/ocaml-corosync, and feel free to contact me if you have any questions!

3 Likes

Hm maybe also show some snippet or example code?

Hi @olleharstedt Certainly! I have updated my Github repo to add some example usages of this binding. I can also paste them here

The following code will query whether your current cluster is quorate:

open Corosync_tools

let _ = 
  let open Quorumtool in 
  match is_quorate () with
  | Ok quorate ->
    Printf.printf "is quorate %b\n" quorate
  | Error e -> 
    print_endline (Corosync_lib.Corotypes.CsError.to_string e)

And this code can tell you the name of your cluster. Note you will need to understand
the return type of each keys stored in the cmap database. See the documentation
of Cmapctl.get for more details

open Corosync_tools
open Corosync_lib

let _ =
  let open Cmap in
  match Cmapctl.get CmapValue.string "totem.cluster_name" with
  | Ok res -> Printf.printf "cluster name %s\n" res
  | Error e -> Corotypes.CsError.to_string e |> print_endline
1 Like