forked from juju/juju
/
manifold.go
31 lines (26 loc) · 1.05 KB
/
manifold.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
// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package logger
import (
"github.com/juju/juju/agent"
"github.com/juju/juju/api/base"
"github.com/juju/juju/api/logger"
"github.com/juju/juju/cmd/jujud/agent/engine"
"github.com/juju/juju/worker"
"github.com/juju/juju/worker/dependency"
)
// ManifoldConfig defines the names of the manifolds on which a
// Manifold will depend.
type ManifoldConfig engine.AgentAPIManifoldConfig
// Manifold returns a dependency manifold that runs a logger
// worker, using the resource names defined in the supplied config.
func Manifold(config ManifoldConfig) dependency.Manifold {
typedConfig := engine.AgentAPIManifoldConfig(config)
return engine.AgentAPIManifold(typedConfig, newWorker)
}
// newWorker trivially wraps NewLogger to specialise a engine.AgentAPIManifold.
var newWorker = func(a agent.Agent, apiCaller base.APICaller) (worker.Worker, error) {
currentConfig := a.CurrentConfig()
loggerFacade := logger.NewState(apiCaller)
return NewLogger(loggerFacade, currentConfig)
}