# README
Redis
This is the basic initialization of this backend:
import (
"log"
"github.com/pulchre/wingman/backend/redis"
)
func main() {
backend, err := redis.Init(redis.Options{})
if err != nil {
log.Fatal(err)
}
}
This is required both for the application and for the manager.
The options available are:
- A go-redis options struct.
BlockingTimeout
time.Duration
- Timeout for blocking commands to Redis.
Internals
Here is an overview of the stages that a job goes through in the Redis backend.
PushJob
:RPUSH
onto the queue.PopJob
:BLPOP
pops the next job off the queue. If no job is on the queue, it blocks until the either a job is pushed, the timeout is reached, or the context is cancelled.LockJob
: If the job has noLockKey
or concurrency is less than 1, we returnwingman.LockNotRequired
(0). A job may have n concurrency. The locks are a Redis key (wingman:lock:LOCK_KEY:LOCK-ID). We randomly try a lock until we exhaust all the locks or get one. If we cannot get a lock, we move it to the held queue (wingman:held:QUEUE).ProcessJob
:SET
set the processing key to the job. (wingman:processing:JOB-ID)ReleaseJob
:DEL
the lock key andLMOVE
a job from the held queue to the front of the queue.ClearJob
:DEL
the processing keyFailJob
:DEL
&SET
. first it deletes the processing key, then sets a failed key to the job (wingman:failed:JOB-ID).
# Functions
No description provided by the author
# Variables
No description provided by the author