本文整理汇总了Golang中github.com/juju/juju/api/watcher.NewNotifyWatcher函数的典型用法代码示例。如果您正苦于以下问题:Golang NewNotifyWatcher函数的具体用法?Golang NewNotifyWatcher怎么用?Golang NewNotifyWatcher使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewNotifyWatcher函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: newStateForVersion
// newStateForVersion creates a new client-side Uniter facade for the
// given version.
func newStateForVersion(
caller base.APICaller,
authTag names.UnitTag,
version int,
) *State {
facadeCaller := base.NewFacadeCallerForVersion(
caller,
uniterFacade,
version,
)
state := &State{
ModelWatcher: common.NewModelWatcher(facadeCaller),
APIAddresser: common.NewAPIAddresser(facadeCaller),
StorageAccessor: NewStorageAccessor(facadeCaller),
facade: facadeCaller,
unitTag: authTag,
}
newWatcher := func(result params.NotifyWatchResult) watcher.NotifyWatcher {
return apiwatcher.NewNotifyWatcher(caller, result)
}
state.LeadershipSettings = NewLeadershipSettingsAccessor(
facadeCaller.FacadeCall,
newWatcher,
ErrIfNotVersionFn(2, state.BestAPIVersion()),
)
return state
}
示例2: WatchForModelConfigChanges
// WatchForModelConfigChanges return a NotifyWatcher waiting for the
// model configuration to change.
func (e *ModelWatcher) WatchForModelConfigChanges() (watcher.NotifyWatcher, error) {
var result params.NotifyWatchResult
err := e.facade.FacadeCall("WatchForModelConfigChanges", nil, &result)
if err != nil {
return nil, err
}
return apiwatcher.NewNotifyWatcher(e.facade.RawAPICaller(), result), nil
}
示例3: WatchAPIHostPorts
// WatchAPIHostPorts watches the host/port addresses of the API servers.
func (a *APIAddresser) WatchAPIHostPorts() (watcher.NotifyWatcher, error) {
var result params.NotifyWatchResult
err := a.facade.FacadeCall("WatchAPIHostPorts", nil, &result)
if err != nil {
return nil, err
}
return apiwatcher.NewNotifyWatcher(a.facade.RawAPICaller(), result), nil
}
示例4: WatchCredential
// WatchCredential returns a watcher which reports when the specified
// credential has changed.
func (c *State) WatchCredential(tag names.CloudCredentialTag) (watcher.NotifyWatcher, error) {
var result params.NotifyWatchResult
err := c.facade.FacadeCall("WatchCredential", nil, &result)
if err != nil {
return nil, errors.Trace(err)
}
if result.Error != nil {
return nil, result.Error
}
return apiwatcher.NewNotifyWatcher(c.facade.RawAPICaller(), result), nil
}
示例5: WatchCleanups
// WatchCleanups calls the server-side WatchCleanups method.
func (api *API) WatchCleanups() (watcher.NotifyWatcher, error) {
var result params.NotifyWatchResult
err := api.facade.FacadeCall("WatchCleanups", nil, &result)
if err != nil {
return nil, err
}
if err := result.Error; err != nil {
return nil, result.Error
}
w := watcher.NewNotifyWatcher(api.facade.RawAPICaller(), result)
return w, nil
}
示例6: WatchMachineErrorRetry
func (st *State) WatchMachineErrorRetry() (watcher.NotifyWatcher, error) {
var result params.NotifyWatchResult
err := st.facade.FacadeCall("WatchMachineErrorRetry", nil, &result)
if err != nil {
return nil, err
}
if err := result.Error; err != nil {
return nil, result.Error
}
w := apiwatcher.NewNotifyWatcher(st.facade.RawAPICaller(), result)
return w, nil
}
示例7: Watch
// Watch implements Client.
func (c *client) Watch() (watcher.NotifyWatcher, error) {
var result params.NotifyWatchResult
err := c.caller.FacadeCall("Watch", nil, &result)
if err != nil {
return nil, errors.Trace(err)
}
if result.Error != nil {
return nil, result.Error
}
w := apiwatcher.NewNotifyWatcher(c.caller.RawAPICaller(), result)
return w, nil
}
示例8: WatchForRebootEvent
// WatchForRebootEvent returns a watcher.NotifyWatcher that reacts to reboot flag
// changes
func (st *State) WatchForRebootEvent() (watcher.NotifyWatcher, error) {
var result params.NotifyWatchResult
if err := st.facade.FacadeCall("WatchForRebootEvent", nil, &result); err != nil {
return nil, err
}
if result.Error != nil {
return nil, result.Error
}
w := watcher.NewNotifyWatcher(st.facade.RawAPICaller(), result)
return w, nil
}
示例9: TestNotifyWatcherStopsWithPendingSend
func (s *watcherSuite) TestNotifyWatcherStopsWithPendingSend(c *gc.C) {
var results params.NotifyWatchResults
args := params.Entities{Entities: []params.Entity{{Tag: s.rawMachine.Tag().String()}}}
err := s.stateAPI.APICall("Machiner", s.stateAPI.BestFacadeVersion("Machiner"), "", "Watch", args, &results)
c.Assert(err, jc.ErrorIsNil)
c.Assert(results.Results, gc.HasLen, 1)
result := results.Results[0]
c.Assert(result.Error, gc.IsNil)
// params.NotifyWatcher conforms to the watcher.NotifyWatcher interface
w := watcher.NewNotifyWatcher(s.stateAPI, result)
wc := watchertest.NewNotifyWatcherC(c, w, s.BackingState.StartSync)
wc.AssertStops()
}
示例10: TestWatchMachine
func (s *watcherSuite) TestWatchMachine(c *gc.C) {
var results params.NotifyWatchResults
args := params.Entities{Entities: []params.Entity{{Tag: s.rawMachine.Tag().String()}}}
err := s.stateAPI.APICall("Machiner", s.stateAPI.BestFacadeVersion("Machiner"), "", "Watch", args, &results)
c.Assert(err, jc.ErrorIsNil)
c.Assert(results.Results, gc.HasLen, 1)
result := results.Results[0]
c.Assert(result.Error, gc.IsNil)
// params.NotifyWatcher conforms to the state.NotifyWatcher interface
w := watcher.NewNotifyWatcher(s.stateAPI, result)
wc := statetesting.NewNotifyWatcherC(c, s.State, w)
wc.AssertOneChange()
statetesting.AssertStop(c, w)
wc.AssertClosed()
}
示例11: TestNotifyWatcherStopsWithPendingSend
func (s *watcherSuite) TestNotifyWatcherStopsWithPendingSend(c *gc.C) {
var results params.NotifyWatchResults
args := params.Entities{Entities: []params.Entity{{Tag: s.rawMachine.Tag().String()}}}
err := s.stateAPI.APICall("Machiner", s.stateAPI.BestFacadeVersion("Machiner"), "", "Watch", args, &results)
c.Assert(err, jc.ErrorIsNil)
c.Assert(results.Results, gc.HasLen, 1)
result := results.Results[0]
c.Assert(result.Error, gc.IsNil)
// params.NotifyWatcher conforms to the state.NotifyWatcher interface
w := watcher.NewNotifyWatcher(s.stateAPI, result)
wc := statetesting.NewNotifyWatcherC(c, s.State, w)
// Now, without reading any changes try stopping the watcher.
statetesting.AssertCanStopWhenSending(c, w)
wc.AssertClosed()
}
示例12: Watch
// Watch starts a NotifyWatcher for the entity with the specified tag.
func Watch(facade base.FacadeCaller, tag names.Tag) (watcher.NotifyWatcher, error) {
var results params.NotifyWatchResults
args := params.Entities{
Entities: []params.Entity{{Tag: tag.String()}},
}
err := facade.FacadeCall("Watch", args, &results)
if err != nil {
return nil, err
}
if len(results.Results) != 1 {
return nil, fmt.Errorf("expected 1 result, got %d", len(results.Results))
}
result := results.Results[0]
if result.Error != nil {
return nil, result.Error
}
return watcher.NewNotifyWatcher(facade.RawAPICaller(), result), nil
}
示例13: WatchMachine
// WatchMachine watches for changes to the specified machine.
func (st *State) WatchMachine(m names.MachineTag) (watcher.NotifyWatcher, error) {
var results params.NotifyWatchResults
args := params.Entities{
Entities: []params.Entity{{Tag: m.String()}},
}
err := st.facade.FacadeCall("WatchMachines", args, &results)
if err != nil {
return nil, err
}
if len(results.Results) != 1 {
panic(errors.Errorf("expected 1 result, got %d", len(results.Results)))
}
result := results.Results[0]
if result.Error != nil {
return nil, result.Error
}
w := apiwatcher.NewNotifyWatcher(st.facade.RawAPICaller(), result)
return w, nil
}
示例14: WatchAddresses
// WatchAddresses returns a watcher for observing changes to the
// unit's addresses. The unit must be assigned to a machine before
// this method is called, and the returned watcher will be valid only
// while the unit's assigned machine is not changed.
func (u *Unit) WatchAddresses() (watcher.NotifyWatcher, error) {
var results params.NotifyWatchResults
args := params.Entities{
Entities: []params.Entity{{Tag: u.tag.String()}},
}
err := u.st.facade.FacadeCall("WatchUnitAddresses", args, &results)
if err != nil {
return nil, err
}
if len(results.Results) != 1 {
return nil, fmt.Errorf("expected 1 result, got %d", len(results.Results))
}
result := results.Results[0]
if result.Error != nil {
return nil, result.Error
}
w := watcher.NewNotifyWatcher(u.st.facade.RawAPICaller(), result)
return w, nil
}
示例15: WatchRetryStrategy
// WatchRetryStrategy returns a notify watcher that looks for changes in the
// retry strategy config for the agent specified by agentTag
// Right now only the boolean that decides whether we retry can be modified.
func (c *Client) WatchRetryStrategy(agentTag names.Tag) (watcher.NotifyWatcher, error) {
var results params.NotifyWatchResults
args := params.Entities{
Entities: []params.Entity{{Tag: agentTag.String()}},
}
err := c.facade.FacadeCall("WatchRetryStrategy", args, &results)
if err != nil {
return nil, errors.Trace(err)
}
if len(results.Results) != 1 {
return nil, fmt.Errorf("expected 1 result, got %d", len(results.Results))
}
result := results.Results[0]
if result.Error != nil {
return nil, errors.Trace(result.Error)
}
w := apiwatcher.NewNotifyWatcher(c.facade.RawAPICaller(), result)
return w, nil
}