mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-21 17:42:50 +08:00

* brought in rafty * moved raft classes into Ocelot and deleted from int project * started to set up rafty in Ocelot * RAFTY INSIDE OCELOT...WOOT * more work adding rafty...just need to get auth working now * rudimentary authenticated raft requests working * asyn await stuff * hacked rafty into the fileconfigurationcontroller...everything seems to be working roughly but I have a lot of refactoring to do * updated to latest rafty that doesnt need an id * hacky but all tests passing * changed admin area set up to use builder not configuration.json, changed admin area auth to use client credentials * missing code coverage * ignore raft sectionf for code coverage * ignore raft sectionf for code coverage * back to normal filters * try exclude attr * missed these * moved client secret to builder for authentication and updated docs * lock to try and fix error accessing identity server created temprsa file on build server * updated postman scripts and changed Ocelot to not always use type handling as this looked crap when manually accessing the configuration endpoint * added rafty docs * changes I missed * added serialisation code we need for rafty to process commands when they proxy to leader * moved controllers into their feature slices
46 lines
1.9 KiB
ReStructuredText
46 lines
1.9 KiB
ReStructuredText
Raft (EXPERIMENTAL DO NOT USE IN PRODUCTION)
|
|
============================================
|
|
|
|
Ocelot has recenely integrated `Rafty <https://github.com/TomPallister/Rafty>`_ which is an implementation of Raft that I have also been working on over the last year. This project is very experimental so please do not use this feature of Ocelot in production until I think it's OK.
|
|
|
|
Raft is a distributed concensus algorythm that allows a cluster of servers (Ocelots) to maintain local state without having a centralised database for storing state (e.g. SQL Server).
|
|
|
|
In order to enable Rafty in Ocelot you must make the following changes to your Startup.cs.
|
|
|
|
.. code-block:: csharp
|
|
|
|
public virtual void ConfigureServices(IServiceCollection services)
|
|
{
|
|
services
|
|
.AddOcelot(Configuration)
|
|
.AddAdministration("/administration", "secret")
|
|
.AddRafty();
|
|
}
|
|
|
|
In addition to this you must add a file called peers.json to your main project and it will look as follows
|
|
|
|
.. code-block:: json
|
|
|
|
{
|
|
"Peers": [{
|
|
"HostAndPort": "http://localhost:5000"
|
|
},
|
|
{
|
|
"HostAndPort": "http://localhost:5002"
|
|
},
|
|
{
|
|
"HostAndPort": "http://localhost:5003"
|
|
},
|
|
{
|
|
"HostAndPort": "http://localhost:5004"
|
|
},
|
|
{
|
|
"HostAndPort": "http://localhost:5001"
|
|
}
|
|
]
|
|
}
|
|
|
|
Each instance of Ocelot must have it's address in the array so that they can communicate using Rafty.
|
|
|
|
Once you have made these configuration changes you must deploy and start each instance of Ocelot using the addresses in the peers.json file. The servers should then start communicating with each other! You can test if everything is working by posting a configuration update and checking it has replicated to all servers by getting there configuration.
|