Commit 97f14670 authored by Vojtech Vitek (V-Teq)'s avatar Vojtech Vitek (V-Teq)

Add config defaults to README

parent d118265c
......@@ -5,7 +5,7 @@
- **Persistent** - Jobs can be either in-memory or persisted on disk<sup>[[1]](https://github.com/antirez/disque#disque-and-disk-persistence)</sup>.
- **Distributed** - Disque pool. Multiple producers, multiple consumers.
- **Job Priority Queue** - Multiple queues. Consumers `Get()` from higher priority queues first.
- **Fault tolerant** - Jobs must be replicated to N nodes before `Add()` returns. Jobs must be `ACK()`ed after `Get()` or they'll be re-queued automatically within a specified `RetryAfter` timeout.
- **Fault tolerant** - Jobs must be replicated to N nodes before `Add()` returns. Consumer must `Ack()` the job within a specified `RetryAfter` timeout or the job will be re-queued automatically.
[![GoDoc](https://godoc.org/github.com/goware/disque?status.png)](https://godoc.org/github.com/goware/disque)
[![Travis](https://travis-ci.org/goware/disque.svg?branch=master)](https://travis-ci.org/goware/disque)
......@@ -44,7 +44,7 @@ func main() {
for {
// Get job from highest priority queue possible. Blocks by default.
job, _ := jobs.Get("urgent", "high", "low") // Left-right priority.
job, _ := jobs.Get("urgent", "high", "low") // Left-to-right priority.
// Do some hard work with the job data.
if err := Process(job.Data); err != nil {
......@@ -58,18 +58,29 @@ func main() {
}
```
## Config (Timeout, Replicate, Delay, Retry, TTL, MaxLen)
## Default configuration
| Config option | Default value | Description |
| ------------- |:-------------:| ------------ |
| Timeout | 0 | Blocks on each operation until it returns. |
| Replicate | 0 | Job doesn't need to be replicated before Add() returns. |
| Delay | 0 | Job is added immediately. |
| RetryAfter | 0 | Job is not re-queued automatically. |
| TTL | 0 | Job lives until it's ACKed. |
| MaxLen | 0 | Unlimited queue. |
## Custom configuration
```go
jobs, _ := disque.Connect("127.0.0.1:7711")
config := disque.Config{
Timeout: time.Second, // Each operation will fail after 1s. It blocks by default.
Replicate: 2, // Add(): Replicate job to at least two nodes before return.
Delay: time.Hour, // Add(): Schedule the job - enqueue after one hour.
RetryAfter: time.Minute, // Add(): Re-queue job after 1min (time between Get() and Ack()).
TTL: 24 * time.Hour, // Add(): Remove the job from queue after one day.
MaxLen: 1000, // Add(): Fail if there are more than 1000 jobs in the queue.
Timeout: time.Second, // Every operation timeouts after 1s.
Replicate: 2, // Replicates job to 2+ nodes before Add() returns.
Delay: time.Hour, // Schedules the job (enqueues after 1h).
RetryAfter: time.Minute, // Re-queues the job after 1min of not being ACKed.
TTL: 24 * time.Hour, // Removes the job from the queue after one day.
MaxLen: 1000, // Fails if there are 1000+ jobs in the queue.
}
// Apply globally.
......@@ -81,7 +92,7 @@ jobs.With(config).Add(data, "queue")
// Apply single option to a single operation.
jobs.Timeout(time.Second).Get("queue", "queue2")
jobs.MaxLen(1000).RetryAfter(time.Minute).Add(data, "queue")
jobs.Timeout(time.Second).Add(data, "queue")
jobs.TTL(24 * time.Hour).Add(data, "queue")
```
## License
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment