Show server status

This commit is contained in:
Smaug123
2022-10-27 12:55:38 +01:00
parent 8441e75fb2
commit 110a04c4f2
2 changed files with 26 additions and 5 deletions

View File

@@ -164,9 +164,15 @@ type private ServerSpecialisation =
| Candidate of CandidateState
type ServerStatus =
| Leader
| Leader of int<Term>
| Follower
| Candidate
| Candidate of int<Term>
override this.ToString () =
match this with
| Leader term -> sprintf "Leader in term %i" term
| Candidate term -> sprintf "Candidate in term %i" term
| Follower -> "Follower"
type private ServerAction<'a> =
| BeginElection
@@ -462,8 +468,8 @@ type Server<'a>
member this.State =
match currentType with
| ServerSpecialisation.Leader _ -> ServerStatus.Leader
| ServerSpecialisation.Candidate _ -> ServerStatus.Candidate
| ServerSpecialisation.Leader _ -> ServerStatus.Leader persistentState.CurrentTerm
| ServerSpecialisation.Candidate _ -> ServerStatus.Candidate persistentState.CurrentTerm
| ServerSpecialisation.Follower -> ServerStatus.Follower
type Cluster<'a> =
@@ -479,6 +485,10 @@ type Cluster<'a> =
this.Servers.[i / 1<ServerId>].TriggerTimeout ()
this.Servers.[i / 1<ServerId>].Sync ()
member this.State (i : int<ServerId>) : ServerStatus = this.Servers.[i / 1<ServerId>].State
member this.ClusterSize : int = this.Servers.Length
type Network<'a> =
internal
{