-
Notifications
You must be signed in to change notification settings - Fork 331
Description
I am trying to do some unit synchronization and I need to wait until the unit finishes deactivating . It is possible to do with a SubscriptionSet or with adaptation of SubscribeUnitsCustomContext, but both will result in polling the ListUnitsContext with some interval which seems like an overkill to me.
While exploring the code I have found this:
go-systemd/dbus/subscription_set.go
Lines 32 to 38 in 4dc4ee6
| // SubscribeContext starts listening for dbus events for all of the units in the set. | |
| // Returns channels identical to conn.SubscribeUnits. | |
| func (s *SubscriptionSet) SubscribeContext(ctx context.Context) (<-chan map[string]*UnitStatus, <-chan error) { | |
| // TODO: Make fully evented by using systemd 209 with properties changed values | |
| return s.conn.SubscribeUnitsCustomContext(ctx, time.Second, 0, | |
| mismatchUnitStatus, |
It seems there used to be a plan 8 years ago for the units in the SubscriptionSet to use PropertiesChanged signal for individaul units if I understand correctly.
This is already being done but for all units in Subscribe method
go-systemd/dbus/subscription.go
Lines 34 to 42 in 4dc4ee6
| // explicitly call Unsubscribe(). | |
| func (c *Conn) Subscribe() error { | |
| c.sigconn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0, | |
| "type='signal',interface='org.freedesktop.systemd1.Manager',member='UnitNew'") | |
| c.sigconn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0, | |
| "type='signal',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged'") | |
| return c.sigobj.Call("org.freedesktop.systemd1.Manager.Subscribe", 0).Store() | |
| } |
and you could use this functionality by SetPropertiesSubscriber and SetSubStateSubscriber but one will updates for all units.
I wonder if it is possible and makes sense to do a feature to be able to subscribe for propertuies change for individual unit.
It is possible add unit path= to the subscribe D-Bus call to get the updates only on that unit but that will interfere with Subscribe if it is to be called later at some point.
Let me know what you think and we glad to help if it makes sense to have something like this.