本文整理汇总了Golang中github.com/juju/juju/worker.NewNotifyWorker函数的典型用法代码示例。如果您正苦于以下问题:Golang NewNotifyWorker函数的具体用法?Golang NewNotifyWorker怎么用?Golang NewNotifyWorker使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewNotifyWorker函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:imoapps,项目名称:juju,代码行数:13,代码来源:machiner.go
示例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)
}
开发者ID:imoapps,项目名称:juju,代码行数:10,代码来源:worker.go
示例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
}
开发者ID:imoapps,项目名称:juju,代码行数:9,代码来源:connected.go
示例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)
}
开发者ID:Pankov404,项目名称:juju,代码行数:10,代码来源:worker.go
示例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
}
开发者ID:klyachin,项目名称:juju,代码行数:12,代码来源:worker.go
示例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)
}
开发者ID:imoapps,项目名称:juju,代码行数:11,代码来源:logger.go
示例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
}
开发者ID:Pankov404,项目名称:juju,代码行数:15,代码来源:worker.go
示例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,
})
}
开发者ID:Pankov404,项目名称:juju,代码行数:14,代码来源:certupdater.go
示例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)
}
开发者ID:kapilt,项目名称:juju,代码行数:11,代码来源:notifyworker_test.go
示例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,
})
}
开发者ID:imoapps,项目名称:juju,代码行数:14,代码来源:certupdater.go
示例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
}
开发者ID:Pankov404,项目名称:juju,代码行数:12,代码来源:reboot.go
示例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
}
开发者ID:klyachin,项目名称:juju,代码行数:16,代码来源:networker.go
示例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)
}
开发者ID:rogpeppe,项目名称:juju,代码行数:15,代码来源:machineenvironmentworker.go
示例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)
}
开发者ID:kapilt,项目名称:juju,代码行数:18,代码来源:notifyworker_test.go
示例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)
}
开发者ID:kapilt,项目名称:juju,代码行数:18,代码来源:notifyworker_test.go
示例16: newNotifyHandlerWorker
func newNotifyHandlerWorker(c *gc.C, setupError, handlerError, teardownError error) (*notifyHandler, worker.Worker) {
nh := ¬ifyHandler{
actions: nil,
handled: make(chan struct{}, 1),
setupError: setupError,
teardownError: teardownError,
handlerError: handlerError,
watcher: &testNotifyWatcher{
changes: make(chan struct{}),
},
setupDone: make(chan struct{}),
}
w := worker.NewNotifyWorker(nh)
select {
case <-nh.setupDone:
case <-time.After(coretesting.ShortWait):
c.Error("Failed waiting for notifyHandler.Setup to be called during SetUpTest")
}
return nh, w
}
开发者ID:imoapps,项目名称:juju,代码行数:20,代码来源:notifyworker_test.go
示例17: NewAPIAddressUpdater
// NewAPIAddressUpdater returns a worker.Worker that runs state.Cleanup()
// if the CleanupWatcher signals documents marked for deletion.
func NewAPIAddressUpdater(addresser APIAddresser, setter APIAddressSetter) worker.Worker {
return worker.NewNotifyWorker(&APIAddressUpdater{
addresser: addresser,
setter: setter,
})
}
开发者ID:klyachin,项目名称:juju,代码行数:8,代码来源:apiaddressupdater.go
示例18: 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 {
kw := &keyupdaterWorker{st: st, tag: agentConfig.Tag()}
return worker.NewNotifyWorker(kw)
}
开发者ID:klyachin,项目名称:juju,代码行数:7,代码来源:worker.go
示例19: writeEnvironmentFile
// disk.
first bool
}
var _ worker.NotifyWatchHandler = (*proxyWorker)(nil)
// New returns a worker.Worker that updates proxy environment variables for the
// process; and, if writeSystemFiles is true, for the whole machine.
var New = func(api *environment.Facade, writeSystemFiles bool) worker.Worker {
logger.Debugf("write system files: %v", writeSystemFiles)
envWorker := &proxyWorker{
api: api,
writeSystemFiles: writeSystemFiles,
first: true,
}
return worker.NewNotifyWorker(envWorker)
}
func (w *proxyWorker) writeEnvironmentFile() error {
// Writing the environment file is handled by executing the script for two
// primary reasons:
//
// 1: In order to have the local provider specify the environment settings
// for the machine agent running on the host, this worker needs to run,
// but it shouldn't be touching any files on the disk. If however there is
// an ubuntu user, it will. This shouldn't be a problem.
//
// 2: On cloud-instance ubuntu images, the ubuntu user is uid 1000, but in
// the situation where the ubuntu user has been created as a part of the
// manual provisioning process, the user will exist, and will not have the
// same uid/gid as the default cloud image.
开发者ID:Pankov404,项目名称:juju,代码行数:31,代码来源:proxyupdater.go
示例20: 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.
func NewMachiner(st MachineAccessor, agentConfig agent.Config) worker.Worker {
mr := &Machiner{st: st, tag: agentConfig.Tag().(names.MachineTag)}
return worker.NewNotifyWorker(mr)
}
开发者ID:Pankov404,项目名称:juju,代码行数:7,代码来源:machiner.go
注:本文中的github.com/juju/juju/worker.NewNotifyWorker函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论