Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.

Commit

Permalink
Merge branch release-0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
albrow committed Feb 25, 2015
2 parents c382692 + 9f0406c commit 959e311
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A persistent and flexible background jobs library for go.

[![GoDoc](https://godoc.org/github.com/albrow/jobs?status.svg)](https://godoc.org/github.com/albrow/jobs)

Version: 0.1.0
Version: 0.1.1

Jobs is powered by redis and supports the following features:

Expand Down Expand Up @@ -163,15 +163,15 @@ grabbed from the database that did not yet finish will be requeued and picked up

There are two known ways that a job may be executed more than once:

1) If there is a power failure or hard reset while a worker is in the middle of executing a job, the job may be
stuck in a half-executed state. Since there is no way to know how much of the job was successfully completed,
the job will be requeued and picked up by a different pool, where it may be partially or fully executed
more than once.
2) If a pool becomes disconnected, it will be considered stale and its jobs will be requeued and reclaimed
by a different pool. However, if the stale pool is able to partly or fully execute jobs without a reliable
internet connection, any jobs belonging to the stale pool might be executed more than once. You can increase
the [StaleTimeout](https://godoc.org/github.com/albrow/jobs#PoolConfig) parameter for a pool to make this
scenario less likely.
1. If there is a power failure or hard reset while a worker is in the middle of executing a job, the job may be
stuck in a half-executed state. Since there is no way to know how much of the job was successfully completed,
the job will be requeued and picked up by a different pool, where it may be partially or fully executed
more than once.
2. If a pool becomes disconnected, it will be considered stale and its jobs will be requeued and reclaimed
by a different pool. However, if the stale pool is able to partly or fully execute jobs without a reliable
internet connection, any jobs belonging to the stale pool might be executed more than once. You can increase
the [StaleTimeout](https://godoc.org/github.com/albrow/jobs#PoolConfig) parameter for a pool to make this
scenario less likely.


License
Expand Down
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// package jobs is a persistent and flexible background jobs library.
//
// Version: 0.1.0
// Version: 0.1.1
//
// Jobs is powered by redis and supports the following features:
//
Expand Down
3 changes: 2 additions & 1 deletion job.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,11 @@ func (j *Job) Reschedule(time time.Time) error {
unixNanoTime := time.UTC().UnixNano()
t.command("HSET", redis.Args{j.key(), "time", unixNanoTime}, nil)
t.setStatus(j, StatusQueued)
j.time = unixNanoTime
t.addJobToTimeIndex(j)
if err := t.exec(); err != nil {
return err
}
j.time = unixNanoTime
j.status = StatusQueued
return nil
}
Expand Down
1 change: 1 addition & 0 deletions job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func TestJobReschedule(t *testing.T) {
t.Errorf("Unexpected error in job.Reschedule: %s", err.Error())
}
expectJobFieldEquals(t, job, "time", unixNanoTime, int64Converter)
expectJobInTimeIndex(t, job)

// Run through a set of possible state paths and make sure the result is
// always what we expect
Expand Down

0 comments on commit 959e311

Please sign in to comment.