Unit fetches a unit from the manager. If the unit does not exist, it returns the Unit zero-value as a placeholder unit, because units may depend on other units that have not yet been created.
(id ID)
| 128 | // it returns the Unit zero-value as a placeholder unit, because |
| 129 | // units may depend on other units that have not yet been created. |
| 130 | func (m *Manager) Unit(id ID) (Unit, error) { |
| 131 | if id == "" { |
| 132 | return Unit{}, xerrors.Errorf("unit ID cannot be empty: %w", ErrUnitIDRequired) |
| 133 | } |
| 134 | |
| 135 | m.mu.RLock() |
| 136 | defer m.mu.RUnlock() |
| 137 | |
| 138 | return m.units[id], nil |
| 139 | } |
| 140 | |
| 141 | func (m *Manager) IsReady(id ID) (bool, error) { |
| 142 | if id == "" { |