Crate asura

Crate asura 

Source
Expand description

This is an implementation of ASURA. You can use this algorithm to compute the placement node of the data in consistent manner.

use asura::*;

let mut cluster = Cluster::new();
cluster.add_nodes([
    Node { node_id: 0, cap: 10. },
    Node { node_id: 1, cap: 5. },
    Node { node_id: 2, cap: 8. },
]);
cluster.remove_node(1);

let data_key = 43287642786;
let assign_node_id = cluster.calc_candidates(data_key, 1)[0];
assert!(assign_node_id < 3);
assert_ne!(assign_node_id, 1);

Structs§

Cluster
Node

Type Aliases§

NodeId