Skip to content

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