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

new feature: (optional) Queue priorities #74

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

enriquebris
Copy link

This PR adds a new feature: (optional) queue priorities.

Starting now queue's priority could be defined, meaning that jobs from a queue with higher priority will be pulled before jobs from a queue with lower priority.

How to define priorities:

settings := goworker.WorkerSettings{
		URI:            "redis://localhost:6379/",
		Connections:    100,
		Queues:         []string{"med-priority", "low-priority", "high-priority"},
		QueuesPriority: map[string]int{
			"high-priority": 10,
			"med-priority": 100,
                        "low-priority": 200,
		},
		UseNumber:      true,
		ExitOnComplete: false,
		Concurrency:    2,
		Namespace:      "resque:",
		Interval:       5.0,
	}

goworker.SetSettings(settings)

Values

Priorities could be defined from 0 to the max int value. Smaller values mean higher priority. Zero is the highest priority.

Those queues with no defined priority will automatically get the highest priority (zero).

How optional is this?

All the following scenarios are valid:

  • No priorities are defined
  • All queues have priorities
  • Some queues have priorities

Compatibility

This new feature does not introduce any compatibility issue with code bases using previous versions.

Other PRs

This PR includes #71

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.

1 participant