// NewPinger returns an object that can be pinged by calling its Ping method. // If this method is not called frequently enough, the connection will be // dropped. func NewPinger( st *state.State, resources *common.Resources, authorizer common.Authorizer, ) ( pinger, error, ) { pingTimeout, ok := resources.Get("pingTimeout").(*pingTimeout) if !ok { return nullPinger{}, nil } return pingTimeout, nil }
func newNotifyWatcher(st *state.State, resources *common.Resources, auth common.Authorizer, id string) (interface{}, error) { if !isAgent(auth) { return nil, common.ErrPerm } watcher, ok := resources.Get(id).(state.NotifyWatcher) if !ok { return nil, common.ErrUnknownWatcher } return &srvNotifyWatcher{ watcher: watcher, id: id, resources: resources, }, nil }
func newClientAllWatcher(st *state.State, resources *common.Resources, auth common.Authorizer, id string) (interface{}, error) { if !auth.AuthClient() { return nil, common.ErrPerm } watcher, ok := resources.Get(id).(*multiwatcher.Watcher) if !ok { return nil, common.ErrUnknownWatcher } return &srvClientAllWatcher{ watcher: watcher, id: id, resources: resources, }, nil }