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:
@@ -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
|
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.
|
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
|
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
|
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
|
status with `SetConverged`, and to notify when the particular timeout has been
|
||||||
reached by waiting on `ConvergedTimer`.
|
reached by waiting on `ConvergedTimer`.
|
||||||
@@ -237,7 +237,7 @@ thing, but provide a `select`-free interface for different coding situations.
|
|||||||
```golang
|
```golang
|
||||||
// Watch is the listener and main loop for this resource.
|
// Watch is the listener and main loop for this resource.
|
||||||
func (obj *FooRes) Watch(processChan chan event.Event) error {
|
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
|
// setup the Foo resource
|
||||||
var err error
|
var err error
|
||||||
|
|||||||
@@ -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.
|
// Watch is the primary listener for this resource and it outputs events.
|
||||||
func (obj *ExecRes) Watch(processChan chan event.Event) error {
|
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 send = false // send event?
|
||||||
var exit = false
|
var exit = false
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ func (obj *FileRes) Validate() error {
|
|||||||
// must be restarted. On a clean exit it returns nil.
|
// must be restarted. On a clean exit it returns nil.
|
||||||
// FIXME: Also watch the source directory when using obj.Source !!!
|
// FIXME: Also watch the source directory when using obj.Source !!!
|
||||||
func (obj *FileRes) Watch(processChan chan event.Event) error {
|
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
|
var err error
|
||||||
obj.recWatcher, err = recwatch.NewRecWatcher(obj.Path, obj.Recurse)
|
obj.recWatcher, err = recwatch.NewRecWatcher(obj.Path, obj.Recurse)
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ func (obj *HostnameRes) Validate() error {
|
|||||||
|
|
||||||
// Watch is the primary listener for this resource and it outputs events.
|
// Watch is the primary listener for this resource and it outputs events.
|
||||||
func (obj *HostnameRes) Watch(processChan chan event.Event) error {
|
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!!
|
// if we share the bus with others, we will get each others messages!!
|
||||||
bus, err := util.SystemBusPrivateUsable() // don't share the bus connection!
|
bus, err := util.SystemBusPrivateUsable() // don't share the bus connection!
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ func (obj *MsgRes) journalPriority() journal.Priority {
|
|||||||
|
|
||||||
// Watch is the primary listener for this resource and it outputs events.
|
// Watch is the primary listener for this resource and it outputs events.
|
||||||
func (obj *MsgRes) Watch(processChan chan event.Event) error {
|
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
|
// notify engine that we're running
|
||||||
if err := obj.Running(processChan); err != nil {
|
if err := obj.Running(processChan); err != nil {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ func (obj *NoopRes) Validate() error {
|
|||||||
|
|
||||||
// Watch is the primary listener for this resource and it outputs events.
|
// Watch is the primary listener for this resource and it outputs events.
|
||||||
func (obj *NoopRes) Watch(processChan chan event.Event) error {
|
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
|
// notify engine that we're running
|
||||||
if err := obj.Running(processChan); err != nil {
|
if err := obj.Running(processChan); err != nil {
|
||||||
|
|||||||
@@ -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
|
// 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 {
|
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
|
// this resource depends on systemd ensure that it's running
|
||||||
if !systemdUtil.IsRunningSystemd() {
|
if !systemdUtil.IsRunningSystemd() {
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ Loop:
|
|||||||
|
|
||||||
// Watch is the primary listener for this resource and it outputs events.
|
// Watch is the primary listener for this resource and it outputs events.
|
||||||
func (obj *PasswordRes) Watch(processChan chan event.Event) error {
|
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
|
var err error
|
||||||
obj.recWatcher, err = recwatch.NewRecWatcher(obj.path, false)
|
obj.recWatcher, err = recwatch.NewRecWatcher(obj.path, false)
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ func (obj *PkgRes) Validate() error {
|
|||||||
// TODO: https://github.com/hughsie/PackageKit/issues/109
|
// TODO: https://github.com/hughsie/PackageKit/issues/109
|
||||||
// TODO: https://github.com/hughsie/PackageKit/issues/110
|
// TODO: https://github.com/hughsie/PackageKit/issues/110
|
||||||
func (obj *PkgRes) Watch(processChan chan event.Event) error {
|
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()
|
bus := packagekit.NewBus()
|
||||||
if bus == nil {
|
if bus == nil {
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ type Base interface {
|
|||||||
SetWatching(bool)
|
SetWatching(bool)
|
||||||
RegisterConverger()
|
RegisterConverger()
|
||||||
UnregisterConverger()
|
UnregisterConverger()
|
||||||
Converger() converger.ConvergerUID
|
ConvergerUID() converger.ConvergerUID
|
||||||
GetState() ResState
|
GetState() ResState
|
||||||
SetState(ResState)
|
SetState(ResState)
|
||||||
DoSend(chan event.Event, string) (bool, error)
|
DoSend(chan event.Event, string) (bool, error)
|
||||||
@@ -307,9 +307,9 @@ func (obj *BaseRes) UnregisterConverger() {
|
|||||||
obj.cuid.Unregister()
|
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.
|
// 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
|
return obj.cuid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
// This signals to the engine to kick off the initial CheckApply resource check.
|
||||||
func (obj *BaseRes) Running(processChan chan event.Event) error {
|
func (obj *BaseRes) Running(processChan chan event.Event) error {
|
||||||
obj.StateOK(false) // assume we're initially dirty
|
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
|
cuid.SetConverged(false) // a reasonable initial assumption
|
||||||
close(obj.started) // send started signal
|
close(obj.started) // send started signal
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ func (obj *SvcRes) Validate() error {
|
|||||||
|
|
||||||
// Watch is the primary listener for this resource and it outputs events.
|
// Watch is the primary listener for this resource and it outputs events.
|
||||||
func (obj *SvcRes) Watch(processChan chan event.Event) error {
|
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
|
// obj.Name: svc name
|
||||||
if !systemdUtil.IsRunningSystemd() {
|
if !systemdUtil.IsRunningSystemd() {
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ func (obj *TimerRes) newTicker() *time.Ticker {
|
|||||||
|
|
||||||
// Watch is the primary listener for this resource and it outputs events.
|
// Watch is the primary listener for this resource and it outputs events.
|
||||||
func (obj *TimerRes) Watch(processChan chan event.Event) error {
|
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
|
// create a time.Ticker for the given interval
|
||||||
obj.ticker = obj.newTicker()
|
obj.ticker = obj.newTicker()
|
||||||
|
|||||||
@@ -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.
|
// Watch is the primary listener for this resource and it outputs events.
|
||||||
func (obj *VirtRes) Watch(processChan chan event.Event) error {
|
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()
|
conn, err := obj.connect()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user