爆肝,重构框架,你懂得
This commit is contained in:
@@ -11,14 +11,14 @@ using Yi.Framework.Common.IOCOptions;
|
||||
using CSRedis;
|
||||
using static CSRedis.CSRedisClient;
|
||||
|
||||
namespace Yi.Framework.Core
|
||||
namespace Yi.Framework.Core.Cache
|
||||
{
|
||||
public abstract class CacheInvoker
|
||||
{
|
||||
|
||||
public virtual bool Exits(string key)
|
||||
public virtual bool Exits(string key)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public virtual T Get<T>(string key)
|
||||
{
|
||||
@@ -147,7 +147,7 @@ namespace Yi.Framework.Core
|
||||
|
||||
public virtual string[] Keys(string pattern)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
|
||||
namespace Yi.Framework.Core.ConsulExtend
|
||||
namespace Yi.Framework.Core.Consul
|
||||
{
|
||||
public abstract class AbstractConsulDispatcher
|
||||
{
|
||||
@@ -16,7 +16,7 @@ namespace Yi.Framework.Core.ConsulExtend
|
||||
|
||||
public AbstractConsulDispatcher(IOptionsMonitor<ConsulClientOption> consulClientOption)
|
||||
{
|
||||
this._ConsulClientOption = consulClientOption.CurrentValue;
|
||||
_ConsulClientOption = consulClientOption.CurrentValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -28,7 +28,7 @@ namespace Yi.Framework.Core.ConsulExtend
|
||||
{
|
||||
Uri uri = new Uri(mappingUrl);
|
||||
string serviceName = uri.Host;
|
||||
string addressPort = this.ChooseAddress(serviceName);
|
||||
string addressPort = ChooseAddress(serviceName);
|
||||
return $"{uri.Scheme}://{addressPort}{uri.PathAndQuery}";
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ namespace Yi.Framework.Core.ConsulExtend
|
||||
{
|
||||
ConsulClient client = new ConsulClient(c =>
|
||||
{
|
||||
c.Address = new Uri($"http://{this._ConsulClientOption.IP}:{this._ConsulClientOption.Port}/");
|
||||
c.Datacenter = this._ConsulClientOption.Datacenter;
|
||||
c.Address = new Uri($"http://{_ConsulClientOption.IP}:{_ConsulClientOption.Port}/");
|
||||
c.Datacenter = _ConsulClientOption.Datacenter;
|
||||
});
|
||||
AgentService agentService = null;
|
||||
//var response = client.Agent.Services().Result.Response;
|
||||
@@ -59,10 +59,10 @@ namespace Yi.Framework.Core.ConsulExtend
|
||||
{
|
||||
serviceList.Add(new KeyValuePair<string, AgentService>(i.ToString(), entrys[i].Service));
|
||||
}
|
||||
this._CurrentAgentServiceDictionary = serviceList.ToArray();
|
||||
_CurrentAgentServiceDictionary = serviceList.ToArray();
|
||||
|
||||
int index = this.GetIndex();
|
||||
agentService = this._CurrentAgentServiceDictionary[index].Value;
|
||||
int index = GetIndex();
|
||||
agentService = _CurrentAgentServiceDictionary[index].Value;
|
||||
|
||||
return $"{agentService.Address}:{agentService.Port}";
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using Consul;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
|
||||
namespace Yi.Framework.Core.ConsulExtend
|
||||
namespace Yi.Framework.Core.Consul
|
||||
{
|
||||
/// <summary>
|
||||
/// 平均
|
||||
@@ -23,7 +23,7 @@ namespace Yi.Framework.Core.ConsulExtend
|
||||
}
|
||||
set
|
||||
{
|
||||
_iTotalCount = value >= Int32.MaxValue ? 0 : value;
|
||||
_iTotalCount = value >= int.MaxValue ? 0 : value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Yi.Framework.Core.ConsulExtend
|
||||
/// <returns></returns>
|
||||
protected override int GetIndex()
|
||||
{
|
||||
return new Random(iTotalCount++).Next(0, base._CurrentAgentServiceDictionary.Length);
|
||||
return new Random(iTotalCount++).Next(0, _CurrentAgentServiceDictionary.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using Consul;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
|
||||
namespace Yi.Framework.Core.ConsulExtend
|
||||
namespace Yi.Framework.Core.Consul
|
||||
{
|
||||
/// <summary>
|
||||
/// 轮询
|
||||
@@ -23,7 +23,7 @@ namespace Yi.Framework.Core.ConsulExtend
|
||||
}
|
||||
set
|
||||
{
|
||||
_iTotalCount = value >= Int32.MaxValue ? 0 : value;
|
||||
_iTotalCount = value >= int.MaxValue ? 0 : value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Yi.Framework.Core.ConsulExtend
|
||||
/// <returns></returns>
|
||||
protected override int GetIndex()
|
||||
{
|
||||
return iTotalCount++ % base._CurrentAgentServiceDictionary.Length;
|
||||
return iTotalCount++ % _CurrentAgentServiceDictionary.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using Consul;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
|
||||
namespace Yi.Framework.Core.ConsulExtend
|
||||
namespace Yi.Framework.Core.Consul
|
||||
{
|
||||
/// <summary>
|
||||
/// 权重
|
||||
@@ -23,7 +23,7 @@ namespace Yi.Framework.Core.ConsulExtend
|
||||
}
|
||||
set
|
||||
{
|
||||
_iTotalCount = value >= Int32.MaxValue ? 0 : value;
|
||||
_iTotalCount = value >= int.MaxValue ? 0 : value;
|
||||
}
|
||||
}
|
||||
public WeightDispatcher(IOptionsMonitor<ConsulClientOption> consulClientOption) : base(consulClientOption)
|
||||
@@ -36,17 +36,17 @@ namespace Yi.Framework.Core.ConsulExtend
|
||||
{
|
||||
ConsulClient client = new ConsulClient(c =>
|
||||
{
|
||||
c.Address = new Uri($"http://{base._ConsulClientOption.IP}:{base._ConsulClientOption.Port}/");
|
||||
c.Datacenter = base._ConsulClientOption.Datacenter;
|
||||
c.Address = new Uri($"http://{_ConsulClientOption.IP}:{_ConsulClientOption.Port}/");
|
||||
c.Datacenter = _ConsulClientOption.Datacenter;
|
||||
});
|
||||
AgentService agentService = null;
|
||||
var response = client.Agent.Services().Result.Response;
|
||||
|
||||
this._CurrentAgentServiceDictionary = response.Where(s => s.Value.Service.Equals(serviceName, StringComparison.OrdinalIgnoreCase)).ToArray();
|
||||
_CurrentAgentServiceDictionary = response.Where(s => s.Value.Service.Equals(serviceName, StringComparison.OrdinalIgnoreCase)).ToArray();
|
||||
|
||||
|
||||
var serviceDictionaryNew = new List<AgentService>();
|
||||
foreach (var service in base._CurrentAgentServiceDictionary)
|
||||
foreach (var service in _CurrentAgentServiceDictionary)
|
||||
{
|
||||
serviceDictionaryNew.AddRange(Enumerable.Repeat(service.Value, int.TryParse(service.Value.Tags?[0], out int iWeight) ? 1 : iWeight));
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Const;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using JwtRegisteredClaimNames = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames;
|
||||
|
||||
namespace Yi.Framework.Core
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Job;
|
||||
|
||||
namespace Yi.Framework.Core
|
||||
namespace Yi.Framework.Core.Quartz
|
||||
{
|
||||
public class QuartzInvoker
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user