/
reporter.go
67 lines (54 loc) · 2.46 KB
/
reporter.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2015 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.
package dependency
// Reporter defines an interface for extracting human-relevant information
// from a worker.
type Reporter interface {
// Report returns a map describing the state of the receiver. It is expected
// to be goroutine-safe.
//
// It is polite and helpful to use the Key* constants and conventions defined
// and described in this package, where appropriate, but that's for the
// convenience of the humans that read the reports; we don't and shouldn't
// have any code that depends on particular Report formats.
Report() map[string]interface{}
}
// The Key constants describe the constant features of an Engine's Report.
const (
// KeyState applies to a worker; possible values are "starting", "started",
// "stopping", or "stopped". Or it might be something else, in distant
// Reporter implementations; don't make assumptions.
KeyState = "state"
// KeyError holds some relevant error. In the case of an Engine, this will be:
// * any internal error indicating incorrect operation; or
// * the most important fatal error encountered by any worker; or
// * nil, if none of the above apply;
// ...and the value should not be presumed to be stable until the engine
// state is "stopped".
//
// In the case of a manifold, it will always hold the most recent error
// returned by the associated worker (or its start func); and will be
// rewritten whenever a worker state is set to "started" or "stopped".
//
// In the case of a resource access, it holds any error encountered when
// trying to find or convert the resource.
KeyError = "error"
// KeyManifolds holds a map of manifold name to further data (including
// dependency inputs; current worker state; and any relevant report/error
// for the associated current/recent worker.)
KeyManifolds = "manifolds"
// KeyReport holds an arbitrary map of information returned by a manifold
// Worker that is also a Reporter.
KeyReport = "report"
// KeyInputs holds the names of the manifolds on which this one depends.
KeyInputs = "inputs"
// KeyName holds the name of some resource.
KeyName = "name"
// KeyType holds a string representation of the type by which a resource
// was accessed.
KeyType = "type"
// KeyStartCount holds the number of times the worker has been started.
KeyStartCount = "start-count"
// KeyLastStart holds the time of when the worker was last started.
KeyLastStart = "started"
)