MCPcopy Index your code
hub / github.com/coder/coder / Register

Method Register

agent/unit/manager.go:101–120  ·  view source on GitHub ↗

Register adds a unit to the manager if it is not already registered. If a Unit is already registered (per the ID field), it is not updated.

(id ID)

Source from the content-addressed store, hash-verified

99// Register adds a unit to the manager if it is not already registered.
100// If a Unit is already registered (per the ID field), it is not updated.
101func (m *Manager) Register(id ID) error {
102 m.mu.Lock()
103 defer m.mu.Unlock()
104
105 if id == "" {
106 return xerrors.Errorf("registering unit %q: %w", id, ErrUnitIDRequired)
107 }
108
109 if m.registered(id) {
110 return xerrors.Errorf("registering unit %q: %w", id, ErrUnitAlreadyRegistered)
111 }
112
113 m.units[id] = Unit{
114 id: id,
115 status: StatusPending,
116 ready: true,
117 }
118
119 return nil
120}
121
122// registered checks if a unit is registered in the manager.
123func (m *Manager) registered(id ID) bool {

Callers 15

TestManager_RegisterFunction · 0.95
TestManager_UpdateStatusFunction · 0.95
TestManager_ToDOTFunction · 0.95
DRPCRegisterProvisionerFunction · 0.45
DRPCRegisterTailnetFunction · 0.45
TestDERPExpvarCollectorFunction · 0.45
SyncStartMethod · 0.45

Calls 4

registeredMethod · 0.95
LockMethod · 0.45
UnlockMethod · 0.45
ErrorfMethod · 0.45

Tested by 8

TestManager_RegisterFunction · 0.76
TestManager_UpdateStatusFunction · 0.76
TestManager_ToDOTFunction · 0.76
TestDERPExpvarCollectorFunction · 0.36