resources: Rename Converger to ConvergerUID

This is more correct since we need the Converger method to return the
actual converger!
This commit is contained in:
James Shubin
2016-12-23 23:32:05 -05:00
parent 3a098377cb
commit 45820b4ce3
14 changed files with 17 additions and 17 deletions

View File

@@ -224,7 +224,7 @@ The engine might be asked to shutdown when the entire state of the system has
not seen any changes for some duration of time. In order for the engine to be
able to make this determination, each resource must report its converged state.
To do this, the `Watch` method should get the `ConvergedUID` handle that has
been prepared for it by the engine. This is done by calling the `Converger`
been prepared for it by the engine. This is done by calling the `ConvergerUID`
method on the resource object. The result can be used to set the converged
status with `SetConverged`, and to notify when the particular timeout has been
reached by waiting on `ConvergedTimer`.
@@ -237,7 +237,7 @@ thing, but provide a `select`-free interface for different coding situations.
```golang
// Watch is the listener and main loop for this resource.
func (obj *FooRes) Watch(processChan chan event.Event) error {
cuid := obj.Converger() // get the converger uid used to report status
cuid := obj.ConvergerUID() // get the converger uid used to report status
// setup the Foo resource
var err error

View File

@@ -110,7 +110,7 @@ func (obj *ExecRes) BufioChanScanner(scanner *bufio.Scanner) (chan string, chan
// Watch is the primary listener for this resource and it outputs events.
func (obj *ExecRes) Watch(processChan chan event.Event) error {
cuid := obj.Converger() // get the converger uid used to report status
cuid := obj.ConvergerUID() // get the converger uid used to report status
var send = false // send event?
var exit = false

View File

@@ -141,7 +141,7 @@ func (obj *FileRes) Validate() error {
// must be restarted. On a clean exit it returns nil.
// FIXME: Also watch the source directory when using obj.Source !!!
func (obj *FileRes) Watch(processChan chan event.Event) error {
cuid := obj.Converger() // get the converger uid used to report status
cuid := obj.ConvergerUID() // get the converger uid used to report status
var err error
obj.recWatcher, err = recwatch.NewRecWatcher(obj.Path, obj.Recurse)

View File

@@ -108,7 +108,7 @@ func (obj *HostnameRes) Validate() error {
// Watch is the primary listener for this resource and it outputs events.
func (obj *HostnameRes) Watch(processChan chan event.Event) error {
cuid := obj.Converger() // get the converger uid used to report status
cuid := obj.ConvergerUID() // get the converger uid used to report status
// if we share the bus with others, we will get each others messages!!
bus, err := util.SystemBusPrivateUsable() // don't share the bus connection!

View File

@@ -135,7 +135,7 @@ func (obj *MsgRes) journalPriority() journal.Priority {
// Watch is the primary listener for this resource and it outputs events.
func (obj *MsgRes) Watch(processChan chan event.Event) error {
cuid := obj.Converger() // get the converger uid used to report status
cuid := obj.ConvergerUID() // get the converger uid used to report status
// notify engine that we're running
if err := obj.Running(processChan); err != nil {

View File

@@ -59,7 +59,7 @@ func (obj *NoopRes) Validate() error {
// Watch is the primary listener for this resource and it outputs events.
func (obj *NoopRes) Watch(processChan chan event.Event) error {
cuid := obj.Converger() // get the converger uid used to report status
cuid := obj.ConvergerUID() // get the converger uid used to report status
// notify engine that we're running
if err := obj.Running(processChan); err != nil {

View File

@@ -95,7 +95,7 @@ func (obj *NspawnRes) Validate() error {
// Watch for state changes and sends a message to the bus if there is a change
func (obj *NspawnRes) Watch(processChan chan event.Event) error {
cuid := obj.Converger() // get the converger uid used to report status
cuid := obj.ConvergerUID() // get the converger uid used to report status
// this resource depends on systemd ensure that it's running
if !systemdUtil.IsRunningSystemd() {

View File

@@ -168,7 +168,7 @@ Loop:
// Watch is the primary listener for this resource and it outputs events.
func (obj *PasswordRes) Watch(processChan chan event.Event) error {
cuid := obj.Converger() // get the converger uid used to report status
cuid := obj.ConvergerUID() // get the converger uid used to report status
var err error
obj.recWatcher, err = recwatch.NewRecWatcher(obj.path, false)

View File

@@ -109,7 +109,7 @@ func (obj *PkgRes) Validate() error {
// TODO: https://github.com/hughsie/PackageKit/issues/109
// TODO: https://github.com/hughsie/PackageKit/issues/110
func (obj *PkgRes) Watch(processChan chan event.Event) error {
cuid := obj.Converger() // get the converger uid used to report status
cuid := obj.ConvergerUID() // get the converger uid used to report status
bus := packagekit.NewBus()
if bus == nil {

View File

@@ -132,7 +132,7 @@ type Base interface {
SetWatching(bool)
RegisterConverger()
UnregisterConverger()
Converger() converger.ConvergerUID
ConvergerUID() converger.ConvergerUID
GetState() ResState
SetState(ResState)
DoSend(chan event.Event, string) (bool, error)
@@ -307,9 +307,9 @@ func (obj *BaseRes) UnregisterConverger() {
obj.cuid.Unregister()
}
// Converger returns the ConvergerUID for the resource. This should be called
// ConvergerUID returns the ConvergerUID for the resource. This should be called
// by the Watch method of the resource to set the converged state.
func (obj *BaseRes) Converger() converger.ConvergerUID {
func (obj *BaseRes) ConvergerUID() converger.ConvergerUID {
return obj.cuid
}

View File

@@ -112,7 +112,7 @@ func (obj *BaseRes) ReadEvent(ev *event.Event) (exit, send bool) {
// This signals to the engine to kick off the initial CheckApply resource check.
func (obj *BaseRes) Running(processChan chan event.Event) error {
obj.StateOK(false) // assume we're initially dirty
cuid := obj.Converger() // get the converger uid used to report status
cuid := obj.ConvergerUID() // get the converger uid used to report status
cuid.SetConverged(false) // a reasonable initial assumption
close(obj.started) // send started signal

View File

@@ -75,7 +75,7 @@ func (obj *SvcRes) Validate() error {
// Watch is the primary listener for this resource and it outputs events.
func (obj *SvcRes) Watch(processChan chan event.Event) error {
cuid := obj.Converger() // get the converger uid used to report status
cuid := obj.ConvergerUID() // get the converger uid used to report status
// obj.Name: svc name
if !systemdUtil.IsRunningSystemd() {

View File

@@ -74,7 +74,7 @@ func (obj *TimerRes) newTicker() *time.Ticker {
// Watch is the primary listener for this resource and it outputs events.
func (obj *TimerRes) Watch(processChan chan event.Event) error {
cuid := obj.Converger() // get the converger uid used to report status
cuid := obj.ConvergerUID() // get the converger uid used to report status
// create a time.Ticker for the given interval
obj.ticker = obj.newTicker()

View File

@@ -132,7 +132,7 @@ func (obj *VirtRes) connect() (conn libvirt.VirConnection, err error) {
// Watch is the primary listener for this resource and it outputs events.
func (obj *VirtRes) Watch(processChan chan event.Event) error {
cuid := obj.Converger() // get the converger uid used to report status
cuid := obj.ConvergerUID() // get the converger uid used to report status
conn, err := obj.connect()
if err != nil {