forked from juju/juju
/
shim.go
33 lines (28 loc) · 926 Bytes
/
shim.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 2016 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package undertaker
import (
"github.com/juju/errors"
"github.com/juju/juju/api/base"
"github.com/juju/juju/api/undertaker"
"github.com/juju/juju/api/watcher"
"github.com/juju/juju/worker"
)
// NewFacade creates a Facade from a base.APICaller, by calling the
// constructor in api/undertaker that returns a more specific type.
func NewFacade(apiCaller base.APICaller) (Facade, error) {
facade, err := undertaker.NewClient(apiCaller, watcher.NewNotifyWatcher)
if err != nil {
return nil, errors.Trace(err)
}
return facade, nil
}
// NewFacade creates a worker.Worker from a Config, by calling the
// local constructor that returns a more specific type.
func NewWorker(config Config) (worker.Worker, error) {
worker, err := NewUndertaker(config)
if err != nil {
return nil, errors.Trace(err)
}
return worker, nil
}