var timeAfterFunc … type Enforcer … type Manager … // NewManager creates a new idleness manager implementation for the // given idle timeout. It begins in idle mode. func NewManager(enforcer Enforcer, timeout time.Duration) *Manager { … } // resetIdleTimerLocked resets the idle timer to the given duration. Called // when exiting idle mode or when the timer fires and we need to reset it. func (m *Manager) resetIdleTimerLocked(d time.Duration) { … } func (m *Manager) resetIdleTimer(d time.Duration) { … } // handleIdleTimeout is the timer callback that is invoked upon expiry of the // configured idle timeout. The channel is considered inactive if there are no // ongoing calls and no RPC activity since the last time the timer fired. func (m *Manager) handleIdleTimeout() { … } // tryEnterIdleMode instructs the channel to enter idle mode. But before // that, it performs a last minute check to ensure that no new RPC has come in, // making the channel active. // // Return value indicates whether or not the channel moved to idle mode. // // Holds idleMu which ensures mutual exclusion with exitIdleMode. func (m *Manager) tryEnterIdleMode() bool { … } func (m *Manager) EnterIdleModeForTesting() { … } // OnCallBegin is invoked at the start of every RPC. func (m *Manager) OnCallBegin() error { … } // ExitIdleMode instructs m to call the enforcer's ExitIdleMode and update m's // internal state. func (m *Manager) ExitIdleMode() error { … } // OnCallEnd is invoked at the end of every RPC. func (m *Manager) OnCallEnd() { … } func (m *Manager) isClosed() bool { … } func (m *Manager) Close() { … }