goworker icon indicating copy to clipboard operation
goworker copied to clipboard

new feature: (optional) Queue priorities

Open enriquebris opened this issue 4 years ago • 0 comments

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

enriquebris avatar Aug 01 '19 23:08 enriquebris