-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from NicolasConstant/develop
0.11.0 PR
- Loading branch information
Showing
37 changed files
with
1,620 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System.Threading.Tasks; | ||
using BirdsiteLive.Common.Settings; | ||
using BirdsiteLive.DAL.Contracts; | ||
|
||
namespace BirdsiteLive.Pipeline.Tools | ||
{ | ||
public interface IMaxUsersNumberProvider | ||
{ | ||
Task<int> GetMaxUsersNumberAsync(); | ||
} | ||
|
||
public class MaxUsersNumberProvider : IMaxUsersNumberProvider | ||
{ | ||
private readonly InstanceSettings _instanceSettings; | ||
private readonly ITwitterUserDal _twitterUserDal; | ||
|
||
private int _totalUsersCount = -1; | ||
private int _warmUpIterations; | ||
|
||
#region Ctor | ||
public MaxUsersNumberProvider(InstanceSettings instanceSettings, ITwitterUserDal twitterUserDal) | ||
{ | ||
_instanceSettings = instanceSettings; | ||
_twitterUserDal = twitterUserDal; | ||
} | ||
#endregion | ||
|
||
public async Task<int> GetMaxUsersNumberAsync() | ||
{ | ||
// Init data | ||
if (_totalUsersCount == -1) | ||
{ | ||
_totalUsersCount = await _twitterUserDal.GetTwitterUsersCountAsync(); | ||
var warmUpMaxCapacity = _instanceSettings.MaxUsersCapacity / 4; | ||
_warmUpIterations = warmUpMaxCapacity == 0 ? 0 : (int)(_totalUsersCount / (float)warmUpMaxCapacity); | ||
} | ||
|
||
// Return if warm up ended | ||
if (_warmUpIterations <= 0) return _instanceSettings.MaxUsersCapacity; | ||
|
||
// Calculate warm up value | ||
var maxUsers = _warmUpIterations > 0 | ||
? _instanceSettings.MaxUsersCapacity / 4 | ||
: _instanceSettings.MaxUsersCapacity; | ||
_warmUpIterations--; | ||
return maxUsers; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.