Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polling for tasks can be optimized by using /tasks/queue/sizes (instead of tasks/queue/all) #2

Open
erikbrgr opened this issue Dec 16, 2020 · 0 comments

Comments

@erikbrgr
Copy link
Owner

Using tasks/queue/sizes, we can poll for just the tasks registered with the worker. This way, we can pretty much do away with all the below code, with the exception of L69-72.

if (SystemTasks.Contains(taskName))
{
Logger.LogDebug("Task {TaskName} is a system task. Skipping", taskName);
continue;
}
Logger.LogDebug("Determining eligibility of task {TaskName}", taskName);
// We're only interested in tasks within our domain
if (taskDomain != null)
{
if (!taskName.StartsWith(taskDomain)) continue;
// Get rid of the domain prefix
Logger.LogDebug("Removing task domain {TaskDomain} from task {TaskName}", taskDomain, taskName);
taskName = taskName.Replace($"{taskDomain}:", "");
}
// We're only interested in the tasks we registered
if (!SupportedTaskTypes.TryGetValue(taskName, out Type taskType))
{
Logger.LogInformation("Task {TaskName} is not registered with this worker. Skipping", taskName);
continue;
}

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

No branches or pull requests

1 participant