本文整理汇总了Golang中github.com/juju/juju/watcher.NewNotifyWorker函数的典型用法代码示例。如果您正苦于以下问题:Golang NewNotifyWorker函数的具体用法?Golang NewNotifyWorker怎么用?Golang NewNotifyWorker使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewNotifyWorker函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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 watcher.NewNotifyWorker(watcher.NotifyConfig{
Handler: handler,
})
}
开发者ID:felicianotech,项目名称:juju,代码行数:11,代码来源:connected.go
示例2: NewCleaner
// NewCleaner returns a worker.Worker that runs state.Cleanup()
// if the CleanupWatcher signals documents marked for deletion.
func NewCleaner(st StateCleaner) (worker.Worker, error) {
w, err := watcher.NewNotifyWorker(watcher.NotifyConfig{
Handler: &Cleaner{st: st},
})
if err != nil {
return nil, errors.Trace(err)
}
return w, nil
}
开发者ID:exekias,项目名称:juju,代码行数:11,代码来源:cleaner.go
示例3: NewWorker
// NewWorker returns a machine undertaker worker that will watch for
// machines that need to be removed and remove them, cleaning up any
// necessary provider-level resources first.
func NewWorker(api Facade, env environs.Environ) (worker.Worker, error) {
envNetworking, _ := environs.SupportsNetworking(env)
w, err := watcher.NewNotifyWorker(watcher.NotifyConfig{
Handler: &Undertaker{API: api, Releaser: envNetworking},
})
if err != nil {
return nil, errors.Trace(err)
}
return w, nil
}
开发者ID:bac,项目名称:juju,代码行数:13,代码来源:undertaker.go
示例4: NewRetryStrategyWorker
// NewRetryStrategyWorker returns a worker.Worker that returns the current
// retry strategy and bounces when it changes.
func NewRetryStrategyWorker(config WorkerConfig) (worker.Worker, error) {
if err := config.Validate(); err != nil {
return nil, errors.Trace(err)
}
w, err := watcher.NewNotifyWorker(watcher.NotifyConfig{
Handler: retryStrategyHandler{config},
})
if err != nil {
return nil, errors.Trace(err)
}
return &RetryStrategyWorker{w, config.RetryStrategy}, nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:14,代码来源:worker.go
示例5: NewAPIAddressUpdater
// NewAPIAddressUpdater returns a worker.Worker that watches for changes to
// API addresses and then sets them on the APIAddressSetter.
// TODO(fwereade): this should have a config struct, and some validation.
func NewAPIAddressUpdater(addresser APIAddresser, setter APIAddressSetter) (worker.Worker, error) {
handler := &APIAddressUpdater{
addresser: addresser,
setter: setter,
}
w, err := watcher.NewNotifyWorker(watcher.NotifyConfig{
Handler: handler,
})
if err != nil {
return nil, errors.Trace(err)
}
return w, nil
}
开发者ID:exekias,项目名称:juju,代码行数:16,代码来源:apiaddressupdater.go
示例6: 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")
}
handler := &Machiner{config: cfg}
w, err := watcher.NewNotifyWorker(watcher.NotifyConfig{
Handler: handler,
})
if err != nil {
return nil, errors.Trace(err)
}
return w, nil
}
开发者ID:exekias,项目名称:juju,代码行数:19,代码来源:machiner.go
示例7: 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,
}
w, err := watcher.NewNotifyWorker(watcher.NotifyConfig{
Handler: r,
})
return w, errors.Trace(err)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:15,代码来源:reboot.go
示例8: 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, error) {
logger := &Logger{
api: api,
agentConfig: agentConfig,
lastConfig: loggo.LoggerInfo(),
}
log.Debugf("initial log config: %q", logger.lastConfig)
w, err := watcher.NewNotifyWorker(watcher.NotifyConfig{
Handler: logger,
})
if err != nil {
return nil, errors.Trace(err)
}
return w, nil
}
开发者ID:exekias,项目名称:juju,代码行数:17,代码来源:logger.go
示例9: 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, error) {
machineTag, ok := agentConfig.Tag().(names.MachineTag)
if !ok {
return nil, errors.NotValidf("machine tag %v", agentConfig.Tag())
}
if os.HostOS() == os.Windows {
return worker.NewNoOpWorker(), nil
}
w, err := watcher.NewNotifyWorker(watcher.NotifyConfig{
Handler: &keyupdaterWorker{
st: st,
tag: machineTag,
},
})
if err != nil {
return nil, errors.Trace(err)
}
return w, nil
}
开发者ID:exekias,项目名称:juju,代码行数:22,代码来源:worker.go
示例10: 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: newTestNotifyWatcher(),
setupDone: make(chan struct{}),
}
w, err := watcher.NewNotifyWorker(watcher.NotifyConfig{Handler: nh})
c.Assert(err, jc.ErrorIsNil)
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:felicianotech,项目名称:juju,代码行数:19,代码来源:notify_test.go
示例11: writeEnvironmentFile
// time through, even if the proxies are empty, we write the files to
// disk.
first bool
}
// NewWorker returns a worker.Worker that updates proxy environment variables for the
// process; and, if writeSystemFiles is true, for the whole machine.
var NewWorker = func(api *apiproxyupdater.Facade, writeSystemFiles bool) (worker.Worker, error) {
logger.Debugf("write system files: %v", writeSystemFiles)
envWorker := &proxyWorker{
api: api,
writeSystemFiles: writeSystemFiles,
first: true,
}
w, err := watcher.NewNotifyWorker(watcher.NotifyConfig{
Handler: envWorker,
})
if err != nil {
return nil, errors.Trace(err)
}
return w, nil
}
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.
开发者ID:pmatulis,项目名称:juju,代码行数:31,代码来源:proxyupdater.go
注:本文中的github.com/juju/juju/watcher.NewNotifyWorker函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论