const cleanIgnoreInterval … const ignoreInterval … // Subscribe sets up this connection to subscribe to all systemd dbus events. // This is required before calling SubscribeUnits. When the connection closes // systemd will automatically stop sending signals so there is no need to // explicitly call Unsubscribe(). func (c *Conn) Subscribe() error { … } // Unsubscribe this connection from systemd dbus events. func (c *Conn) Unsubscribe() error { … } func (c *Conn) dispatch() { … } // SubscribeUnits returns two unbuffered channels which will receive all changed units every // interval. Deleted units are sent as nil. func (c *Conn) SubscribeUnits(interval time.Duration) (<-chan map[string]*UnitStatus, <-chan error) { … } // SubscribeUnitsCustom is like SubscribeUnits but lets you specify the buffer // size of the channels, the comparison function for detecting changes and a filter // function for cutting down on the noise that your channel receives. func (c *Conn) SubscribeUnitsCustom(interval time.Duration, buffer int, isChanged func(*UnitStatus, *UnitStatus) bool, filterUnit func(string) bool) (<-chan map[string]*UnitStatus, <-chan error) { … } type SubStateUpdate … // SetSubStateSubscriber writes to updateCh when any unit's substate changes. // Although this writes to updateCh on every state change, the reported state // may be more recent than the change that generated it (due to an unavoidable // race in the systemd dbus interface). That is, this method provides a good // way to keep a current view of all units' states, but is not guaranteed to // show every state transition they go through. Furthermore, state changes // will only be written to the channel with non-blocking writes. If updateCh // is full, it attempts to write an error to errCh; if errCh is full, the error // passes silently. func (c *Conn) SetSubStateSubscriber(updateCh chan<- *SubStateUpdate, errCh chan<- error) { … } func (c *Conn) sendSubStateUpdate(unitPath dbus.ObjectPath) { … } func (c *Conn) shouldIgnore(path dbus.ObjectPath) bool { … } func (c *Conn) updateIgnore(path dbus.ObjectPath, info map[string]interface{ … } // without this, ignore would grow unboundedly over time func (c *Conn) cleanIgnore() { … } type PropertiesUpdate … // SetPropertiesSubscriber writes to updateCh when any unit's properties // change. Every property change reported by systemd will be sent; that is, no // transitions will be "missed" (as they might be with SetSubStateSubscriber). // However, state changes will only be written to the channel with non-blocking // writes. If updateCh is full, it attempts to write an error to errCh; if // errCh is full, the error passes silently. func (c *Conn) SetPropertiesSubscriber(updateCh chan<- *PropertiesUpdate, errCh chan<- error) { … } // we don't need to worry about shouldIgnore() here because // sendPropertiesUpdate doesn't call GetProperties() func (c *Conn) sendPropertiesUpdate(unitPath dbus.ObjectPath, changedProps map[string]dbus.Variant) { … }