Skip to content

Conversation

@thailyn
Copy link
Contributor

@thailyn thailyn commented Jun 22, 2019

The HttpTransport will only allow a positive limit that is no larger than the real API limit. A custom, smaller API limit will allow Procurement to play nicely with other applications that perform a known maximum number of API requests per minute.

continue;
}

RemvoeExpiredTasks();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate it's not your typo, could you adjust please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. (I rewrote the class, so, ultimately, it is my typo. :) )

CurrentTasks = new Queue<DateTime>(simultaneiousTasksLimit);
WindowSize = windowSize;
WindowLimit = windowLimit;
SimultaneiousTasksLimit = simultaneiousTasksLimit;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if (Settings.UserSettings.Keys.Contains("ApiRequestLimit") &&
int.TryParse(Settings.UserSettings["ApiRequestLimit"], out customRequestLimit))
{
if (HttpTransport.AdjustThrottleWindowLimit(customRequestLimit))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change the message generation to a ternary please, more succinct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this?

private const string UpdateShopURL = @"https://www.pathofexile.com/forum/edit-thread/{0}";
private const string BumpShopURL = @"https://www.pathofexile.com/forum/post-reply/{0}";

private const int _maximumWindowLimit = 42;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be brought in as an application setting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather not, for two reasons.

  1. This value will likely very rarely -- if ever -- change, so the user will be unlikely to modify the setting. He can also easily make Procurement work very poorly by increasing the value.
  2. This class can't reference the Settings directly, since that would introduce a circular dependency between the projects. Thus -- barring more substantial refactoring I'm not interested in doing now -- it would then have to be set after the static constructor finishes, potentially after it started handling requests.


protected static TaskThrottle InitializeTaskThrottle()
{
return new TaskThrottle(TimeSpan.FromMinutes(1), _maximumWindowLimit, _maximumWindowLimit);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't tell just from the PR, isn't this just going to mindlessly overwrite the previously set task throttle?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would, if it were called again. As written, it is only ever invoked during HttpTransport's static constructor. It's also protected, so it can't be called by other classes, and HttpTransport itself doesn't call it. In any case, I changed it back to not call a function, so it is less ambiguous.

@Stickymaddness
Copy link
Member

I'll take a look at this, and the other outsanding PR's as soon as I can.

Thanks for the continued contributions and effort 👍

The HttpTransport will only allow a positive limit that is no larger
than the real API limit.  A custom, smaller API limit will allow
Procurement to play nicely with other applications that perform a known
maximum number of API requests per minute.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants