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:
libcmap (in memory stats and config database)
libquorum and libvotequorum (query of quorum states)
libcfg (config reload, etc)
libcpg (closed process group, corosync’s model of a cluster)
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