Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package graceful
  4. import (
  5. "context"
  6. )
  7. // Shutdown procedure:
  8. // * cancel ShutdownContext: the registered context consumers have time to do their cleanup (they could use the hammer context)
  9. // * cancel HammerContext: the all context consumers have limited time to do their cleanup (wait for a few seconds)
  10. // * cancel TerminateContext: the registered context consumers have time to do their cleanup (but they shouldn't use shutdown/hammer context anymore)
  11. // * cancel manager context
  12. // If the shutdown is triggered again during the shutdown procedure, the hammer context will be canceled immediately to force to shut down.
  13. // ShutdownContext returns a context.Context that is Done at shutdown
  14. // Callers using this context should ensure that they are registered as a running server
  15. // in order that they are waited for.
  16. func (g *Manager) ShutdownContext() context.Context {
  17. return g.shutdownCtx
  18. }
  19. // HammerContext returns a context.Context that is Done at hammer
  20. // Callers using this context should ensure that they are registered as a running server
  21. // in order that they are waited for.
  22. func (g *Manager) HammerContext() context.Context {
  23. return g.hammerCtx
  24. }
  25. // TerminateContext returns a context.Context that is Done at terminate
  26. // Callers using this context should ensure that they are registered as a terminating server
  27. // in order that they are waited for.
  28. func (g *Manager) TerminateContext() context.Context {
  29. return g.terminateCtx
  30. }