// start is a StartFunc for a Worker manifold. func (config ManifoldConfig) start(context dependency.Context) (worker.Worker, error) { if err := config.validate(); err != nil { return nil, errors.Trace(err) } var apiCaller base.APICaller if err := context.Get(config.APICallerName, &apiCaller); err != nil { return nil, errors.Trace(err) } facade, err := config.NewFacade(apiCaller) if err != nil { return nil, errors.Trace(err) } modelTag, err := apiCaller.ModelTag() if err != nil { return nil, errors.Trace(err) } worker, err := config.NewWorker(Config{ Facade: facade, Model: modelTag.Id(), Check: config.Check, }) if err != nil { return nil, errors.Trace(err) } return worker, nil }
// NewClient creates a new client for accessing the undertaker API. func NewClient(caller base.APICaller, newWatcher NewWatcherFunc) (*Client, error) { modelTag, ok := caller.ModelTag() if !ok { return nil, errors.New("undertaker client is not appropriate for controller-only API") } return &Client{ modelTag: modelTag, caller: base.NewFacadeCaller(caller, "Undertaker"), newWatcher: newWatcher, }, nil }
// NewClient creates a new client for accessing the undertaker API. func NewClient(caller base.APICaller, newWatcher NewWatcherFunc) (*Client, error) { modelTag, err := caller.ModelTag() if err != nil { return nil, errors.Trace(err) } return &Client{ modelTag: modelTag, caller: base.NewFacadeCaller(caller, "Undertaker"), newWatcher: newWatcher, }, nil }
// NewClient creates a new client for accessing the metricsmanager api func NewClient(apiCaller base.APICaller) (*Client, error) { modelTag, err := apiCaller.ModelTag() if err != nil { return nil, errors.Trace(err) } facade := base.NewFacadeCaller(apiCaller, "MetricsManager") return &Client{ modelTag: modelTag, facade: facade, }, nil }
// NewClient creates a new client for accessing the metricsmanager api func NewClient(apiCaller base.APICaller) (*Client, error) { modelTag, ok := apiCaller.ModelTag() if !ok { return nil, errors.New("metricsmanager client is not appropriate for controller-only API") } facade := base.NewFacadeCaller(apiCaller, "MetricsManager") return &Client{ modelTag: modelTag, facade: facade, }, nil }
// NewAPI creates a new client-side machine undertaker facade. func NewAPI(caller base.APICaller, newWatcher NewWatcherFunc) (*API, error) { modelTag, ok := caller.ModelTag() if !ok { return nil, errors.New("machine undertaker client requires a model API connection") } api := API{ facade: base.NewFacadeCaller(caller, "MachineUndertaker"), modelTag: modelTag, newWatcher: newWatcher, } return &api, nil }
// NewAPI returns a new API client for the Singular facade. It exposes methods // for claiming and observing administration responsibility for the apiCaller's // model, on behalf of the supplied controller machine. func NewAPI(apiCaller base.APICaller, controllerTag names.MachineTag) (*API, error) { controllerId := controllerTag.Id() if !names.IsValidMachine(controllerId) { return nil, errors.NotValidf("controller tag") } modelTag, ok := apiCaller.ModelTag() if !ok { return nil, errors.New("cannot use singular API on controller-only connection") } facadeCaller := base.NewFacadeCaller(apiCaller, "Singular") return &API{ modelTag: modelTag, controllerTag: controllerTag, facadeCaller: facadeCaller, }, nil }
// NewAPI returns a new API client for the Singular facade. It exposes methods // for claiming and observing administration responsibility for the apiCaller's // model, on behalf of the supplied controller machine. func NewAPI(apiCaller base.APICaller, controllerTag names.MachineTag) (*API, error) { controllerId := controllerTag.Id() if !names.IsValidMachine(controllerId) { return nil, errors.NotValidf("controller tag") } modelTag, err := apiCaller.ModelTag() if err != nil { return nil, errors.Trace(err) } facadeCaller := base.NewFacadeCaller(apiCaller, "Singular") return &API{ modelTag: modelTag, controllerTag: controllerTag, facadeCaller: facadeCaller, }, nil }