|
|
@ -4,7 +4,6 @@ import ( |
|
|
|
"encoding/json" |
|
|
|
"encoding/json" |
|
|
|
"io" |
|
|
|
"io" |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
"unbewohnte/wecr/logger" |
|
|
|
|
|
|
|
"unbewohnte/wecr/web" |
|
|
|
"unbewohnte/wecr/web" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -33,7 +32,6 @@ func PopLastJob(queue *os.File) (*web.Job, error) { |
|
|
|
offset -= 1 |
|
|
|
offset -= 1 |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
logger.Info("Found job: %+v", job) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
queue.Truncate(currentOffset) |
|
|
|
queue.Truncate(currentOffset) |
|
|
|
return &job, nil |
|
|
|
return &job, nil |
|
|
@ -41,11 +39,10 @@ func PopLastJob(queue *os.File) (*web.Job, error) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func InsertNewJob(queue *os.File, newJob web.Job) error { |
|
|
|
func InsertNewJob(queue *os.File, newJob web.Job) error { |
|
|
|
offset, err := queue.Seek(0, io.SeekEnd) |
|
|
|
_, err := queue.Seek(0, io.SeekEnd) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
logger.Info("Inserting at offset %d", offset) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
encoder := json.NewEncoder(queue) |
|
|
|
encoder := json.NewEncoder(queue) |
|
|
|
err = encoder.Encode(&newJob) |
|
|
|
err = encoder.Encode(&newJob) |
|
|
|