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

Method Close

enterprise/replicasync/replicasync.go:452–493  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

450}
451
452func (m *Manager) Close() error {
453 m.closeMutex.Lock()
454 select {
455 case <-m.closed:
456 m.closeMutex.Unlock()
457 return nil
458 default:
459 }
460 close(m.closed)
461 m.closeCancel()
462 m.closeMutex.Unlock()
463 m.closeWait.Wait()
464 m.mutex.Lock()
465 defer m.mutex.Unlock()
466 ctx, cancelFunc := context.WithTimeout(context.Background(), 5*time.Second)
467 defer cancelFunc()
468 // nolint:gocritic // Updating a replica is a system function.
469 _, err := m.db.UpdateReplica(dbauthz.AsSystemRestricted(ctx), database.UpdateReplicaParams{
470 ID: m.self.ID,
471 UpdatedAt: dbtime.Now(),
472 StartedAt: m.self.StartedAt,
473 StoppedAt: sql.NullTime{
474 Time: dbtime.Now(),
475 Valid: true,
476 },
477 RelayAddress: m.self.RelayAddress,
478 RegionID: m.self.RegionID,
479 Hostname: m.self.Hostname,
480 Version: m.self.Version,
481 Error: m.self.Error,
482 DatabaseLatency: 0, // A stopped replica has no latency.
483 Primary: false, // A stopped replica cannot be primary.
484 })
485 if err != nil {
486 return xerrors.Errorf("update replica: %w", err)
487 }
488 err = m.pubsub.Publish(PubsubEvent, []byte(m.self.ID.String()))
489 if err != nil {
490 return xerrors.Errorf("publish replica update: %w", err)
491 }
492 return nil
493}
494
495// CreateDERPMeshTLSConfig creates a TLS configuration for connecting to peers
496// in the DERP mesh over private networking. It overrides the ServerName to be

Callers 1

scaletestAgentFakeMethod · 0.95

Calls 9

AsSystemRestrictedFunction · 0.92
NowFunction · 0.92
WaitMethod · 0.65
UpdateReplicaMethod · 0.65
PublishMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
ErrorfMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected