本文整理汇总了Golang中github.com/juju/juju/worker.NewNotifyWorker函数的典型用法代码示例。如果您正苦于以下问题:Golang NewNotifyWorker函数的具体用法?Golang NewNotifyWorker怎么用?Golang NewNotifyWorker使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewNotifyWorker函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewMachiner
// NewMachiner returns a Worker that will wait for the identified machine
// to become Dying and make it Dead; or until the machine becomes Dead by
// other means.
//
// The machineDead function will be called immediately after the machine's
// lifecycle is updated to Dead.
func NewMachiner(cfg Config) (worker.Worker, error) {
if err := cfg.Validate(); err != nil {
return nil, errors.Annotate(err, "validating config")
}
mr := &Machiner{config: cfg}
return worker.NewNotifyWorker(mr), nil
}
示例2: NewWorker
// NewWorker returns a worker that keeps track of
// the machine's authorised ssh keys and ensures the
// ~/.ssh/authorized_keys file is up to date.
func NewWorker(st *keyupdater.State, agentConfig agent.Config) worker.Worker {
if os.HostOS() == os.Windows {
return worker.NewNoOpWorker()
}
kw := &keyupdaterWorker{st: st, tag: agentConfig.Tag().(names.MachineTag)}
return worker.NewNotifyWorker(kw)
}
示例3: NewConnectedStatusWorker
// NewConnectedStatusWorker creates a new worker that monitors the meter status of the
// unit and runs the meter-status-changed hook appropriately.
func NewConnectedStatusWorker(cfg ConnectedConfig) (worker.Worker, error) {
handler, err := NewConnectedStatusHandler(cfg)
if err != nil {
return nil, errors.Trace(err)
}
return worker.NewNotifyWorker(handler), nil
}
示例4: NewWorker
// NewWorker returns a worker that keeps track of
// the machine's authorised ssh keys and ensures the
// ~/.ssh/authorized_keys file is up to date.
func NewWorker(st *keyupdater.State, agentConfig agent.Config) worker.Worker {
if version.Current.OS == version.Windows {
return worker.NewNoOpWorker()
}
kw := &keyupdaterWorker{st: st, tag: agentConfig.Tag().(names.MachineTag)}
return worker.NewNotifyWorker(kw)
}
示例5: NewRsyslogConfigWorker
// NewRsyslogConfigWorker returns a worker.Worker that uses
// WatchForRsyslogChanges and updates rsyslog configuration based
// on changes. The worker will remove the configuration file
// on teardown.
func NewRsyslogConfigWorker(st *apirsyslog.State, mode RsyslogMode, tag names.Tag, namespace string, stateServerAddrs []string) (worker.Worker, error) {
handler, err := newRsyslogConfigHandler(st, mode, tag, namespace, stateServerAddrs)
if err != nil {
return nil, err
}
logger.Debugf("starting rsyslog worker mode %v for %q %q", mode, tag, namespace)
return worker.NewNotifyWorker(handler), nil
}
示例6: NewLogger
// NewLogger returns a worker.Worker that uses the notify watcher returned
// from the setup.
func NewLogger(api *logger.State, agentConfig agent.Config) worker.Worker {
logger := &Logger{
api: api,
agentConfig: agentConfig,
lastConfig: loggo.LoggerInfo(),
}
log.Debugf("initial log config: %q", logger.lastConfig)
return worker.NewNotifyWorker(logger)
}
示例7: NewRsyslogConfigWorker
// NewRsyslogConfigWorker returns a worker.Worker that uses
// WatchForRsyslogChanges and updates rsyslog configuration based
// on changes. The worker will remove the configuration file
// on teardown.
func NewRsyslogConfigWorker(st *apirsyslog.State, mode RsyslogMode, tag names.Tag, namespace string, stateServerAddrs []string) (worker.Worker, error) {
if version.Current.OS == version.Windows && mode == RsyslogModeAccumulate {
return worker.NewNoOpWorker(), nil
}
handler, err := newRsyslogConfigHandler(st, mode, tag, namespace, stateServerAddrs)
if err != nil {
return nil, err
}
logger.Debugf("starting rsyslog worker mode %v for %q %q", mode, tag, namespace)
return worker.NewNotifyWorker(handler), nil
}
示例8: NewCertificateUpdater
// NewCertificateUpdater returns a worker.Worker that watches for changes to
// machine addresses and then generates a new state server certificate with those
// addresses in the certificate's SAN value.
func NewCertificateUpdater(addressWatcher AddressWatcher, getter StateServingInfoGetter,
configGetter EnvironConfigGetter, setter StateServingInfoSetter, certChanged chan params.StateServingInfo,
) worker.Worker {
return worker.NewNotifyWorker(&CertificateUpdater{
addressWatcher: addressWatcher,
configGetter: configGetter,
getter: getter,
setter: setter,
certChanged: certChanged,
})
}
示例9: SetUpTest
func (s *notifyWorkerSuite) SetUpTest(c *gc.C) {
s.BaseSuite.SetUpTest(c)
s.actor = ¬ifyHandler{
actions: nil,
handled: make(chan struct{}, 1),
watcher: &testNotifyWatcher{
changes: make(chan struct{}),
},
}
s.worker = worker.NewNotifyWorker(s.actor)
}
示例10: NewCertificateUpdater
// NewCertificateUpdater returns a worker.Worker that watches for changes to
// machine addresses and then generates a new state server certificate with those
// addresses in the certificate's SAN value.
func NewCertificateUpdater(addressWatcher AddressWatcher, getter StateServingInfoGetter,
configGetter EnvironConfigGetter, hostPortsGetter APIHostPortsGetter, setter StateServingInfoSetter,
) worker.Worker {
return worker.NewNotifyWorker(&CertificateUpdater{
addressWatcher: addressWatcher,
configGetter: configGetter,
hostPortsGetter: hostPortsGetter,
getter: getter,
setter: setter,
})
}
示例11: NewReboot
func NewReboot(st *reboot.State, agentConfig agent.Config, machineLock *fslock.Lock) (worker.Worker, error) {
tag, ok := agentConfig.Tag().(names.MachineTag)
if !ok {
return nil, errors.Errorf("Expected names.MachineTag, got %T: %v", agentConfig.Tag(), agentConfig.Tag())
}
r := &Reboot{
st: st,
tag: tag,
machineLock: machineLock,
}
return worker.NewNotifyWorker(r), nil
}
示例12: NewNetworker
// NewNetworker returns a Worker that handles machine networking
// configuration. If there is no /etc/network/interfaces file, an
// error is returned.
func NewNetworker(st *apinetworker.State, agentConfig agent.Config) (worker.Worker, error) {
nw := &networker{
st: st,
tag: agentConfig.Tag().String(),
}
// Verify we have /etc/network/interfaces first, otherwise bail out.
if !CanStart() {
err := fmt.Errorf("missing %q config file", configFileName)
logger.Infof("not starting worker: %v", err)
return nil, err
}
return worker.NewNotifyWorker(nw), nil
}
示例13: NewMachineEnvironmentWorker
// NewMachineEnvironmentWorker returns a worker.Worker that uses the notify
// watcher returned from the setup.
func NewMachineEnvironmentWorker(api *environment.Facade, agentConfig agent.Config) worker.Worker {
// We don't write out system files for the local provider on machine zero
// as that is the host machine.
writeSystemFiles := (agentConfig.Tag() != names.NewMachineTag("0").String() ||
agentConfig.Value(agent.ProviderType) != provider.Local)
logger.Debugf("write system files: %v", writeSystemFiles)
envWorker := &MachineEnvironmentWorker{
api: api,
writeSystemFiles: writeSystemFiles,
first: true,
}
return worker.NewNotifyWorker(envWorker)
}
示例14: TestHandleErrorStopsWorkerAndWatcher
func (s *notifyWorkerSuite) TestHandleErrorStopsWorkerAndWatcher(c *gc.C) {
s.stopWorker(c)
actor := ¬ifyHandler{
actions: nil,
handled: make(chan struct{}, 1),
handlerError: fmt.Errorf("my handling error"),
watcher: &testNotifyWatcher{
changes: make(chan struct{}),
},
}
w := worker.NewNotifyWorker(actor)
actor.watcher.TriggerChange(c)
waitForHandledNotify(c, actor.handled)
err := waitShort(c, w)
c.Check(err, gc.ErrorMatches, "my handling error")
actor.CheckActions(c, "setup", "handler", "teardown")
c.Check(actor.watcher.stopped, jc.IsTrue)
}
示例15: TestSetUpFailureStopsWithTearDown
func (s *notifyWorkerSuite) TestSetUpFailureStopsWithTearDown(c *gc.C) {
// Stop the worker and SetUp again, this time with an error
s.stopWorker(c)
actor := ¬ifyHandler{
actions: nil,
handled: make(chan struct{}, 1),
setupError: fmt.Errorf("my special error"),
watcher: &testNotifyWatcher{
changes: make(chan struct{}),
},
}
w := worker.NewNotifyWorker(actor)
err := waitShort(c, w)
c.Check(err, gc.ErrorMatches, "my special error")
// TearDown is not called on SetUp error.
actor.CheckActions(c, "setup")
c.Check(actor.watcher.stopped, jc.IsTrue)
}