pub trait CoordinationService<Clock: Stopwatch, Message: Clone + Debug, Members, Metadata> {
// Required methods
fn new(id: SystemNodeId, metadata: Metadata) -> Self;
fn leader(&self) -> Option<SystemNodeId>;
fn get_state(&self) -> SystemState;
fn get_current_rule(&self) -> Option<Rule>;
fn update_rule(
&mut self,
communication_service: &mut dyn CommunicationService<Package<SystemNodeId, Message>>,
new_rule: Rule,
);
fn update_members(
&mut self,
communication_service: &mut dyn CommunicationService<Package<SystemNodeId, Message>>,
new_config: UpdateClusterVec,
);
fn update_state(
&mut self,
communication_service: &mut dyn CommunicationService<Package<SystemNodeId, Message>>,
measurement: Measurement,
);
fn process(
&mut self,
communication_service: &mut dyn CommunicationService<Package<SystemNodeId, Message>>,
package: Option<CoordinationPackage<Message>>,
members: Members,
);
}Expand description
This is the main abstraction to be implemented by any coordination algorithm.
Required Methods§
fn new(id: SystemNodeId, metadata: Metadata) -> Self
Sourcefn leader(&self) -> Option<SystemNodeId>
fn leader(&self) -> Option<SystemNodeId>
Returns the ID of the cluster leader, or None if it is not set.
Sourcefn get_state(&self) -> SystemState
fn get_state(&self) -> SystemState
Returns the coordinated state of the system
Sourcefn get_current_rule(&self) -> Option<Rule>
fn get_current_rule(&self) -> Option<Rule>
Returns the current rule coordinated by the system
Sourcefn update_rule(
&mut self,
communication_service: &mut dyn CommunicationService<Package<SystemNodeId, Message>>,
new_rule: Rule,
)
fn update_rule( &mut self, communication_service: &mut dyn CommunicationService<Package<SystemNodeId, Message>>, new_rule: Rule, )
Updates the nodes in the cluster based on [new_config].
Sourcefn update_members(
&mut self,
communication_service: &mut dyn CommunicationService<Package<SystemNodeId, Message>>,
new_config: UpdateClusterVec,
)
fn update_members( &mut self, communication_service: &mut dyn CommunicationService<Package<SystemNodeId, Message>>, new_config: UpdateClusterVec, )
Updates the nodes in the cluster based on [new_config].
Sourcefn update_state(
&mut self,
communication_service: &mut dyn CommunicationService<Package<SystemNodeId, Message>>,
measurement: Measurement,
)
fn update_state( &mut self, communication_service: &mut dyn CommunicationService<Package<SystemNodeId, Message>>, measurement: Measurement, )
Updates the coordinated state of the system based on measurement
Sourcefn process(
&mut self,
communication_service: &mut dyn CommunicationService<Package<SystemNodeId, Message>>,
package: Option<CoordinationPackage<Message>>,
members: Members,
)
fn process( &mut self, communication_service: &mut dyn CommunicationService<Package<SystemNodeId, Message>>, package: Option<CoordinationPackage<Message>>, members: Members, )
Receives a message from another node so that the coordination can occur.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.