gitech

Форк
0
/
context.go 
36 строк · 1.5 Кб
1
// Copyright 2019 The Gitea Authors. All rights reserved.
2
// SPDX-License-Identifier: MIT
3

4
package graceful
5

6
import (
7
	"context"
8
)
9

10
// Shutdown procedure:
11
// * cancel ShutdownContext: the registered context consumers have time to do their cleanup (they could use the hammer context)
12
// * cancel HammerContext: the all context consumers have limited time to do their cleanup (wait for a few seconds)
13
// * cancel TerminateContext: the registered context consumers have time to do their cleanup (but they shouldn't use shutdown/hammer context anymore)
14
// * cancel manager context
15
// If the shutdown is triggered again during the shutdown procedure, the hammer context will be canceled immediately to force to shut down.
16

17
// ShutdownContext returns a context.Context that is Done at shutdown
18
// Callers using this context should ensure that they are registered as a running server
19
// in order that they are waited for.
20
func (g *Manager) ShutdownContext() context.Context {
21
	return g.shutdownCtx
22
}
23

24
// HammerContext returns a context.Context that is Done at hammer
25
// Callers using this context should ensure that they are registered as a running server
26
// in order that they are waited for.
27
func (g *Manager) HammerContext() context.Context {
28
	return g.hammerCtx
29
}
30

31
// TerminateContext returns a context.Context that is Done at terminate
32
// Callers using this context should ensure that they are registered as a terminating server
33
// in order that they are waited for.
34
func (g *Manager) TerminateContext() context.Context {
35
	return g.terminateCtx
36
}
37

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.