7 releases ()
3.1.8-2-2fcda | Nov 29, 2023 |
---|---|
0.2.4 | Jan 27, 2023 |
0.2.3 | Sep 26, 2022 |
0.2.2 | Sep 3, 2021 |
0.1.0 | Jan 28, 2021 |
#973 in Rust patterns
315KB
9K
SLoC
rust-corosync
Rust bindings for corosync
Rust bindings for cfg, cmap, cpg, quorum, votequorum are part of this source tree, but are included here mainly to keep all of the corosync APIs in one place and to ensure that everything is kept up-to-date and properly tested in our CI system.
The correct place to get the Rust crates for corosync is still crates.io as it would be for other crates. These will be updated when we issue a new release of corosync.
https://crates.io/crates/rust-corosync
Of course, if you want to try any new features in the APIs that may have not yet been released then you can try these sources, but please keep in touch with us via email or IRC if you do so.
#clusterlabs or #kronosnet on libera IRC users@clusterlabs.org
lib.rs
:
This crate provides access to the corosync libraries cpg, cfg, cmap, quorum & votequorum from Rust. They are a fairly thin layer around the actual API calls but with Rust data types and iterators.
Corosync is a low-level provider of cluster services for high-availability clusters, for more information about corosync see https://corosync.github.io/corosync/
No more information about corosync itself will be provided here, it is expected that if you feel you need access to the Corosync API calls, you know what they do :)
Example
extern crate rust_corosync as corosync;
use corosync::cmap;
fn main()
{
// Open connection to corosync libcmap
let handle =
match cmap::initialize(cmap::Map::Icmap) {
Ok(h) => {
println!("cmap initialized.");
h
}
Err(e) => {
println!("Error in CMAP (Icmap) init: {}", e);
return;
}
};
// Set a numeric value (this is a generic fn)
match cmap::set_number(handle, "test.test_uint32", 456)
{
Ok(_) => {}
Err(e) => {
println!("Error in CMAP set_u32: {}", e);
return;
}
};
// Get a value - this will be a Data struct
match cmap::get(handle, "test.test_uint32")
{
Ok(v) => {
println!("GOT value {}", v);
}
Err(e) => {
println!("Error in CMAP get: {}", e);
return;
}
};
// Use an iterator
match cmap::CmapIterStart::new(handle, "totem.") {
Ok(cmap_iter) => {
for i in cmap_iter {
println!("ITER: {:?}", i);
}
println!("");
}
Err(e) => {
println!("Error in CMAP iter start: {}", e);
}
}
// Close this connection
match cmap::finalize(handle)
{
Ok(_) => {}
Err(e) => {
println!("Error in CMAP get: {}", e);
return;
}
};
}
Dependencies
~1.5MB
~39K SLoC