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

Function newAPIConnRoutineManager

agent/agent.go:2410–2439  ·  view source on GitHub ↗
(
	gracefulCtx, hardCtx context.Context, logger slog.Logger,
	aAPI proto.DRPCAgentClient28, tAPI tailnetproto.DRPCTailnetClient28,
)

Source from the content-addressed store, hash-verified

2408}
2409
2410func newAPIConnRoutineManager(
2411 gracefulCtx, hardCtx context.Context, logger slog.Logger,
2412 aAPI proto.DRPCAgentClient28, tAPI tailnetproto.DRPCTailnetClient28,
2413) *apiConnRoutineManager {
2414 // routines that remain in operation during graceful shutdown use the remainCtx. They'll still
2415 // exit if the errgroup hits an error, which usually means a problem with the conn.
2416 eg, remainCtx := errgroup.WithContext(hardCtx)
2417
2418 // routines that stop operation during graceful shutdown use the stopCtx, which ends when the
2419 // first of remainCtx or gracefulContext ends (an error or start of graceful shutdown).
2420 //
2421 // +------------------------------------------+
2422 // | hardCtx |
2423 // | +------------------------------------+ |
2424 // | | stopCtx | |
2425 // | | +--------------+ +--------------+ | |
2426 // | | | remainCtx | | gracefulCtx | | |
2427 // | | +--------------+ +--------------+ | |
2428 // | +------------------------------------+ |
2429 // +------------------------------------------+
2430 stopCtx := eitherContext(remainCtx, gracefulCtx)
2431 return &apiConnRoutineManager{
2432 logger: logger,
2433 aAPI: aAPI,
2434 tAPI: tAPI,
2435 eg: eg,
2436 stopCtx: stopCtx,
2437 remainCtx: remainCtx,
2438 }
2439}
2440
2441// startAgentAPI starts a routine that uses the Agent API. c.f. startTailnetAPI which is the same
2442// but for Tailnet.

Callers 1

runMethod · 0.85

Calls 2

eitherContextFunction · 0.85
WithContextMethod · 0.80

Tested by

no test coverage detected