( gracefulCtx, hardCtx context.Context, logger slog.Logger, aAPI proto.DRPCAgentClient28, tAPI tailnetproto.DRPCTailnetClient28, )
| 2408 | } |
| 2409 | |
| 2410 | func 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. |
no test coverage detected