github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/worker/dependency/reporter.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package dependency 5 6 // Reporter defines an interface for extracting human-relevant information 7 // from a worker. 8 type Reporter interface { 9 10 // Report returns a map describing the state of the receiver. It is expected 11 // to be goroutine-safe. 12 // 13 // It is polite and helpful to use the Key* constants and conventions defined 14 // and described in this package, where appropriate, but that's for the 15 // convenience of the humans that read the reports; we don't and shouldn't 16 // have any code that depends on particular Report formats. 17 Report() map[string]interface{} 18 } 19 20 // The Key constants describe the constant features of an Engine's Report. 21 const ( 22 23 // KeyState applies to a worker; possible values are "starting", "started", 24 // "stopping", or "stopped". Or it might be something else, in distant 25 // Reporter implementations; don't make assumptions. 26 KeyState = "state" 27 28 // KeyError holds some relevant error. In the case of an Engine, this will be: 29 // * any internal error indicating incorrect operation; or 30 // * the most important fatal error encountered by any worker; or 31 // * nil, if none of the above apply; 32 // ...and the value should not be presumed to be stable until the engine 33 // state is "stopped". 34 // 35 // In the case of a manifold, it will always hold the most recent error 36 // returned by the associated worker (or its start func); and will be 37 // rewritten whenever a worker state is set to "started" or "stopped". 38 // 39 // In the case of a resource access, it holds any error encountered when 40 // trying to find or convert the resource. 41 KeyError = "error" 42 43 // KeyManifolds holds a map of manifold name to further data (including 44 // dependency inputs; current worker state; and any relevant report/error 45 // for the associated current/recent worker.) 46 KeyManifolds = "manifolds" 47 48 // KeyReport holds an arbitrary map of information returned by a manifold 49 // Worker that is also a Reporter. 50 KeyReport = "report" 51 52 // KeyInputs holds the names of the manifolds on which this one depends. 53 KeyInputs = "inputs" 54 55 // KeyResourceLog holds a slice representing the calls the current worker 56 // made to its getResource func; the type of the output param; and any 57 // error encountered. 58 KeyResourceLog = "resource-log" 59 60 // KeyName holds the name of some resource. 61 KeyName = "name" 62 63 // KeyType holds a string representation of the type by which a resource 64 // was accessed. 65 KeyType = "type" 66 )