Newer
Older
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package core
import (
"fmt"
"github.com/pkg/errors"
"log"
"io"
"bytes"
"sync"
)
type basejob struct {
// Function to call on Collect
collectfunc func(c *Collector) error
// Global lock for all following members.
mu sync.Mutex
// Unique identifier of this job.
id JobId
// The state the job is currently in.
state JobState
// When state is set to Failed, contains the reason
// for this failure.
failure error
// Recorded logs for this job.
logged bytes.Buffer
}
func (bj *basejob) Id() JobId {
bj.mu.Lock()
defer bj.mu.Unlock()
return bj.id
}
func (bj *basejob) State() JobState {
bj.mu.Lock()
defer bj.mu.Unlock()
return bj.state
}
func (bj *basejob) Error() error {
bj.mu.Lock()
defer bj.mu.Unlock()
return bj.failure
}
func (bj *basejob) Collect(c *Collector) error {
return errors.New("not implemented")
}
func (bj *basejob) Log(v ...interface{}) {
log.Output(3, fmt.Sprint(v...))
}
func (bj *basejob) Logf(format string, v ...interface{}) {
log.Output(3, fmt.Sprintf(format, v...))
}
func (bj *basejob) Logs() io.Reader {
panic("not yet implemented")
}