mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-03 16:24:27 -05:00 
			
		
		
		
	- NadekoBot class renamed to Bot
- Implemented grpc based coordinator. Supports restarting, killing single or all shards, as well as getting current shard statuses. (Adaptation of the one used by the public bot) - Coord is setup via coord.yml file - Methods from SelfService which deal with shard/bot restart etc have been moved to ICoordinator (with GrpcRemoteCoordinator being the default implementation atm) - Vastly simplified NadekoBot/Program.cs
This commit is contained in:
		@@ -1,22 +0,0 @@
 | 
			
		||||
using System;
 | 
			
		||||
using Discord;
 | 
			
		||||
 | 
			
		||||
namespace NadekoBot.Common.ShardCom
 | 
			
		||||
{
 | 
			
		||||
    public class ShardComMessage
 | 
			
		||||
    {
 | 
			
		||||
        public int ShardId { get; set; }
 | 
			
		||||
        public ConnectionState ConnectionState { get; set; }
 | 
			
		||||
        public int Guilds { get; set; }
 | 
			
		||||
        public DateTime Time { get; set; }
 | 
			
		||||
 | 
			
		||||
        public ShardComMessage Clone() =>
 | 
			
		||||
            new ShardComMessage
 | 
			
		||||
            {
 | 
			
		||||
                ShardId = ShardId,
 | 
			
		||||
                ConnectionState = ConnectionState,
 | 
			
		||||
                Guilds = Guilds,
 | 
			
		||||
                Time = Time,
 | 
			
		||||
            };
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,28 +0,0 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Newtonsoft.Json;
 | 
			
		||||
using NadekoBot.Core.Services;
 | 
			
		||||
 | 
			
		||||
namespace NadekoBot.Common.ShardCom
 | 
			
		||||
{
 | 
			
		||||
    public class ShardComServer
 | 
			
		||||
    {
 | 
			
		||||
        private readonly IDataCache _cache;
 | 
			
		||||
 | 
			
		||||
        public ShardComServer(IDataCache cache)
 | 
			
		||||
        {
 | 
			
		||||
            _cache = cache;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Start()
 | 
			
		||||
        {
 | 
			
		||||
            var sub = _cache.Redis.GetSubscriber();
 | 
			
		||||
            sub.SubscribeAsync("shardcoord_send", (ch, data) =>
 | 
			
		||||
            {
 | 
			
		||||
                var _ = OnDataReceived(JsonConvert.DeserializeObject<ShardComMessage>(data));
 | 
			
		||||
            }, StackExchange.Redis.CommandFlags.FireAndForget);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public event Func<ShardComMessage, Task> OnDataReceived = delegate { return Task.CompletedTask; };
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user