mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-03-22 09:26:36 +08:00
hangfire测试
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Consul;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
|
||||
namespace Yi.Framework.Core.ConsulExtend
|
||||
{
|
||||
/// <summary>
|
||||
/// 平均
|
||||
/// </summary>
|
||||
public class AverageDispatcher : AbstractConsulDispatcher
|
||||
{
|
||||
#region Identity
|
||||
private static int _iTotalCount = 0;
|
||||
private static int iTotalCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return _iTotalCount;
|
||||
}
|
||||
set
|
||||
{
|
||||
_iTotalCount = value >= Int32.MaxValue ? 0 : value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public AverageDispatcher(IOptionsMonitor<ConsulClientOption> consulClientOption) : base(consulClientOption)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 平均
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected override int GetIndex()
|
||||
{
|
||||
return new Random(iTotalCount++).Next(0, base._CurrentAgentServiceDictionary.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user