github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/worker/logsender/manifold.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package logsender 5 6 import ( 7 "gopkg.in/juju/worker.v1" 8 "gopkg.in/juju/worker.v1/dependency" 9 10 "github.com/juju/juju/api/base" 11 "github.com/juju/juju/api/logsender" 12 "github.com/juju/juju/cmd/jujud/agent/engine" 13 ) 14 15 // ManifoldConfig defines the names of the manifolds on which a Manifold will 16 // depend. 17 type ManifoldConfig struct { 18 APICallerName string 19 LogSource LogRecordCh 20 } 21 22 // Manifold returns a dependency manifold that runs a logger 23 // worker, using the resource names defined in the supplied config. 24 func Manifold(config ManifoldConfig) dependency.Manifold { 25 typedConfig := engine.APIManifoldConfig{ 26 APICallerName: config.APICallerName, 27 } 28 return engine.APIManifold(typedConfig, config.newWorker) 29 } 30 31 func (config ManifoldConfig) newWorker(apiCaller base.APICaller) (worker.Worker, error) { 32 return New(config.LogSource, logsender.NewAPI(apiCaller)), nil 33 }