-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathjobs.go
53 lines (44 loc) · 1020 Bytes
/
jobs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2014 David Persson. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
)
func inspectJob(id uint64) (err error) {
body, err := conn.Peek(id)
stats, _ := conn.StatsJob(id)
if err != nil {
return fmt.Errorf("Unknown job %v", id)
}
printJob(id, body, stats)
return
}
func nextJobs(state string) {
for _, t := range cTubes.Conns {
if id, body, err := peekState(t, state); err == nil {
fmt.Printf("Next %s job in %s:\n", state, t.Name)
stats, _ := conn.StatsJob(id)
printJob(id, body, stats)
fmt.Println()
}
}
}
func printJob(id uint64, body []byte, stats map[string]string) {
fmt.Printf("%25s: %v\n", "id", id)
fmt.Printf("%25s:\n---------------------\n%s\n---------------------\n", "body", body)
var include = []string{
"tube",
"age",
"reserves",
"kicks",
"delay",
"releases",
"pri",
"ttr",
"timeouts",
"buries",
}
printStats(stats, include)
}