-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from andreev-io/ilya/transition-ids
Adding IDs to state machine transitions and adding transition statuses
- Loading branch information
Showing
5 changed files
with
257 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
use crate::message::Message; | ||
use crate::{message::Message, state_machine::StateMachineTransition}; | ||
use std::time::Duration; | ||
|
||
// Cluster provides the means of communication of a replica with the rest of the | ||
// cluster and the user. | ||
pub trait Cluster<A> { | ||
pub trait Cluster<T> | ||
where | ||
T: StateMachineTransition, | ||
{ | ||
// This function is used to deliver messages to target replicas. The | ||
// algorithm assumes that send can silently fail. | ||
fn send(&self, to_id: usize, message: Message<A>); | ||
fn send(&self, to_id: usize, message: Message<T>); | ||
// This function is used to received messages for the replicas. This | ||
// function must block until timeout expires or a message is received, | ||
// whichever comes first. | ||
fn receive_timeout(&self, timeout: Duration) -> Option<Message<A>>; | ||
fn receive_timeout(&self, timeout: Duration) -> Option<Message<T>>; | ||
// This function is used to receive actions from the user that the | ||
// distributed state machine needs to replicate and apply. All replicas poll | ||
// this function periodically but only Leaders merit the return value. | ||
// Non-Leaders ignore the return value of get_action. | ||
fn get_actions(&self) -> Vec<A>; | ||
fn get_transitions(&self) -> Vec<T>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.