Skip to content

Commit

Permalink
Prepare release
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Maruszak <maruszaktomasz@gmail.com>
  • Loading branch information
zarusz committed Nov 29, 2022
1 parent fbc3e15 commit 1484b3f
Show file tree
Hide file tree
Showing 52 changed files with 414 additions and 393 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ The strategic aim for SlimCluster is to implement other algorithms to make distr
The path to a stable production release:

* Step 1: Implement the SWIM membership over UDP + sample (90% complete).
* Step 2: Documentation.
* Step 3: Implement the Raft over TCP/UDP + sample.
* Step 4: Documentation.
* Step 5: Other extensions and flavor (Redis Pub/Sub).
* :white_check_mark: Step 1: Implement the SWIM membership over UDP + sample.
* :white_large_square: Step 2: Documentation on SWIM membership.
* :white_large_square: Step 3: Implement the Raft over TCP/UDP + sample.
* :white_large_square: Step 4: Documentation on Raft consensus.
* :white_large_square: Step 5: Other extensions and flavor.

## Packages

Expand All @@ -35,8 +35,8 @@ The path to a stable production release:
| `SlimCluster` | The core cluster interfaces | [![NuGet](https://img.shields.io/nuget/v/SlimCluster.svg)](https://www.nuget.org/packages/SlimCluster) |
| `SlimCluster.Membership` | The membership core interfaces | [![NuGet](https://img.shields.io/nuget/v/SlimCluster.Membership.svg)](https://www.nuget.org/packages/SlimCluster.Membership) |
| `SlimCluster.Membership.Swim` | The SWIM membership algorithm implementation over UDP | [![NuGet](https://img.shields.io/nuget/v/SlimCluster.Membership.Swim.svg)](https://www.nuget.org/packages/SlimCluster.Membership.Swim) |
| `SlimCluster.Concensus` | The concensus protocol core interfaces | [![NuGet](https://img.shields.io/nuget/v/SlimCluster.Concensus.svg)](https://www.nuget.org/packages/SlimCluster.Concensus) |
| `SlimCluster.Concensus.Raft` | Raft RPC implemented over TCP | [![NuGet](https://img.shields.io/nuget/v/SlimCluster.Concensus.Raft.svg)](https://www.nuget.org/packages/SlimCluster.Concensus.Raft) |
| `SlimCluster.Concensus` | The consensus protocol core interfaces | [![NuGet](https://img.shields.io/nuget/v/SlimCluster.Consensus.svg)](https://www.nuget.org/packages/SlimCluster.Consensus) |
| `SlimCluster.Consensus.Raft` | Raft RPC implemented over TCP | [![NuGet](https://img.shields.io/nuget/v/SlimCluster.Consensus.Raft.svg)](https://www.nuget.org/packages/SlimCluster.Consensus.Raft) |
| `SlimCluster.Serialization` | The core serialization interfaces | [![NuGet](https://img.shields.io/nuget/v/SlimCluster.Serialization.svg)](https://www.nuget.org/packages/SlimCluster.Serialization) |
| `SlimCluster.Serialization.Json` | JSON serialization plugin | [![NuGet](https://img.shields.io/nuget/v/SlimCluster.Serialization.Json.svg)](https://www.nuget.org/packages/SlimCluster.Serialization.Json) |

Expand Down
3 changes: 2 additions & 1 deletion build/tasks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ $projects = @(
"SlimCluster",

"SlimCluster.Membership",

"SlimCluster.Membership.Swim",

#"SlimCluster.Strategy.Raft",

"SlimCluster.Serialization",
"SlimCluster.Serialization.Json"
)
Expand Down
106 changes: 106 additions & 0 deletions src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,109 @@ csharp_preferred_modifier_order = public,protected,private,static,readonly,overr

#prefer properties not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_property = false:suggestion
csharp_indent_labels = no_change
csharp_space_around_binary_operators = before_and_after
csharp_using_directive_placement = inside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_throw_expression = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_prefer_utf8_string_literals = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
csharp_prefer_static_local_function = true:suggestion
csharp_style_prefer_readonly_struct = true:suggestion
csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent

[*.{cs,vb}]
#### Naming styles ####

# Naming rules

dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
end_of_line = crlf
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_namespace_match_folder = true:suggestion
dotnet_style_readonly_field = true:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:silent
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
dotnet_style_allow_multiple_blank_lines_experimental = true:silent
dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
2 changes: 1 addition & 1 deletion src/Common.Properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageIcon>icon.png</PackageIcon>
<Version>0.7.0-rc1</Version>
<Version>0.7.0</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<LangVersion>latest</LangVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/Samples/SlimCluster.Samples.ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using SlimCluster.Membership;
using SlimCluster.Membership.Swim;
using SlimCluster.Serialization.Json;
using SlimCluster.Strategy.Raft;
using SlimCluster.Consensus.Raft;
using System.Text;

public class CommandLineOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\SlimCluster.Membership.Swim\SlimCluster.Membership.Swim.csproj" />
<ProjectReference Include="..\..\SlimCluster.Serialization.Json\SlimCluster.Serialization.Json.csproj" />
<ProjectReference Include="..\..\SlimCluster.Strategy.Raft\SlimCluster.Strategy.Raft.csproj" />
<ProjectReference Include="..\..\SlimCluster.Consensus.Raft\SlimCluster.Consensus.Raft.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
29 changes: 29 additions & 0 deletions src/SlimCluster.Consensus.Raft/AbstractStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace SlimCluster.Consensus.Raft;

using SlimCluster;

public abstract class AbstractStatus : IStatus
{
public Guid Id { get; }

public string Name { get; }

protected AbstractStatus(Guid id, string name)
{
Id = id;
Name = name;
}

#region equals

public override bool Equals(object? obj)
=> obj is AbstractStatus state && Id.Equals(state.Id);

public override int GetHashCode()
=> HashCode.Combine(Id);

#endregion

public override string ToString()
=> Name;
}
18 changes: 18 additions & 0 deletions src/SlimCluster.Consensus.Raft/LogEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace SlimCluster.Consensus.Raft;

public class LogEntry
{
public int Index { get; set; }
public int Term { get; set; }
/// <summary>
/// Command for the <see cref="IStateMachine"/>.
/// </summary>
public object Command { get; set; }

public LogEntry(int index, int term, object command)
{
Index = index;
Term = term;
Command = command;
}
}
13 changes: 13 additions & 0 deletions src/SlimCluster.Consensus.Raft/RaftCandidateState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace SlimCluster.Consensus.Raft;

public class RaftCandidateState
{
public int Term { get; set; }
public ISet<string> RecivedVotesFrom { get; set; }

public RaftCandidateState(int term)
{
Term = term;
RecivedVotesFrom = new HashSet<string>();
}
}
21 changes: 21 additions & 0 deletions src/SlimCluster.Consensus.Raft/RaftCluster.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace SlimCluster.Consensus.Raft;

public class RaftCluster : ICluster
{
public string ClusterId { get; protected set; }

public IReadOnlyCollection<INode> Members { get; protected set; }

public INode? LeaderNode { get; protected set; }

public IClusterStatus Status { get; protected set; }

public RaftCluster(string clusterId)
{
ClusterId = clusterId;
Members = new List<INode>();
LeaderNode = null;
Status = RaftClusterStatus.Initializing;
}
}

15 changes: 15 additions & 0 deletions src/SlimCluster.Consensus.Raft/RaftClusterStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace SlimCluster.Consensus.Raft;

using SlimCluster;

public class RaftClusterStatus : AbstractStatus, IClusterStatus
{
protected RaftClusterStatus(Guid id, string name) : base(id, name)
{
}

public static readonly RaftClusterStatus Initializing = new (new Guid("{8939D9A3-7B4F-4B6D-9248-F8086346C1F7}"), "Initializing");
public static readonly RaftClusterStatus Working = new (new Guid("{87A7A4EE-1B22-4BAE-9021-FB56698BA6C8}"), "Working");
public static readonly RaftClusterStatus Waiting = new (new Guid("{A5DED565-8580-4ED8-BB73-E1F102127322}"), "Waiting");
}

13 changes: 13 additions & 0 deletions src/SlimCluster.Consensus.Raft/RaftLeaderState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace SlimCluster.Consensus.Raft;

public class RaftLeaderState
{
public IDictionary<string, int> NextIndex { get; protected set; }
public IDictionary<string, int> MatchIndex { get; protected set; }

public RaftLeaderState()
{
NextIndex = new Dictionary<string, int>();
MatchIndex = new Dictionary<string, int>();
}
}
44 changes: 44 additions & 0 deletions src/SlimCluster.Consensus.Raft/RaftNode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
namespace SlimCluster.Consensus.Raft;

using SlimCluster.Membership;

public class RaftNode
{
private readonly IClusterMembership clusterMembership;

#region persistent state

public int CurrentTerm { get; protected set; }
public string? VotedFor { get; protected set; }
public IList<LogEntry> Log { get; protected set; }
public Snapshot? Snapshot { get; protected set; }

#endregion

#region volatile state

public int CommitIndex { get; protected set; }
public int LastApplied { get; protected set; }

#endregion

public RaftLeaderState? LeaderState { get; protected set; }
public RaftCandidateState? CandidateState { get; protected set; }

public RaftNode(IClusterMembership clusterMembership)
{
this.clusterMembership = clusterMembership;

CurrentTerm = 0;
VotedFor = null;
Log = new List<LogEntry>();
Snapshot = null;

CommitIndex = 0;
LastApplied = 0;

LeaderState = null;
CandidateState = null;
}
}

14 changes: 14 additions & 0 deletions src/SlimCluster.Consensus.Raft/RaftNodeStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace SlimCluster.Consensus.Raft;

using SlimCluster;

public class RaftNodeStatus : AbstractStatus, INodeStatus
{
protected RaftNodeStatus(Guid id, string name) : base(id, name)
{
}

public static readonly RaftNodeStatus Leader = new (new Guid("{FF564377-5F12-473E-8FC0-E44BAFE74BA8}"), "Leader");
public static readonly RaftNodeStatus Follower = new (new Guid("{0F5DB060-5ADB-4973-9EEE-A6B8FD5CEEC8}"), "Follower");
public static readonly RaftNodeStatus Candidate = new (new Guid("{BC46D901-FDE0-4D54-8E7F-78129627138C}"), "Candidate");
}
23 changes: 23 additions & 0 deletions src/SlimCluster.Consensus.Raft/SlimCluster.Consensus.Raft.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="../Common.Properties.xml" />

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Description>Raft consensus algorithm implementation for a distributed .NET service</Description>
<PackageTags>SlimCluster Cluster Consensus Raft</PackageTags>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\SlimCluster.Membership\SlimCluster.Membership.csproj" />
<ProjectReference Include="..\SlimCluster\SlimCluster.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="..\icon.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>

</Project>
Loading

0 comments on commit 1484b3f

Please sign in to comment.