forked from juju/juju
/
manifold.go
33 lines (27 loc) · 968 Bytes
/
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
32
33
// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package logsender
import (
"gopkg.in/juju/worker.v1"
"gopkg.in/juju/worker.v1/dependency"
"github.com/juju/juju/api/base"
"github.com/juju/juju/api/logsender"
"github.com/juju/juju/cmd/jujud/agent/engine"
)
// ManifoldConfig defines the names of the manifolds on which a Manifold will
// depend.
type ManifoldConfig struct {
APICallerName string
LogSource LogRecordCh
}
// 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.APIManifoldConfig{
APICallerName: config.APICallerName,
}
return engine.APIManifold(typedConfig, config.newWorker)
}
func (config ManifoldConfig) newWorker(apiCaller base.APICaller) (worker.Worker, error) {
return New(config.LogSource, logsender.NewAPI(apiCaller)), nil
}