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

Method pollWhile

cli/cliui/agent.go:355–367  ·  view source on GitHub ↗

pollWhile polls the agent while the condition is true. It fetches the agent on each iteration and returns the updated agent when the condition is false, the context is canceled, or an error occurs.

(ctx context.Context, agent codersdk.WorkspaceAgent, cond func(agent codersdk.WorkspaceAgent) bool)

Source from the content-addressed store, hash-verified

353// on each iteration and returns the updated agent when the condition is false,
354// the context is canceled, or an error occurs.
355func (aw *agentWaiter) pollWhile(ctx context.Context, agent codersdk.WorkspaceAgent, cond func(agent codersdk.WorkspaceAgent) bool) (codersdk.WorkspaceAgent, error) {
356 var err error
357 for cond(agent) {
358 agent, err = aw.fetchAgent(ctx)
359 if err != nil {
360 return agent, xerrors.Errorf("fetch: %w", err)
361 }
362 }
363 if err = ctx.Err(); err != nil {
364 return agent, err
365 }
366 return agent, nil
367}
368
369func troubleshootingMessage(agent codersdk.WorkspaceAgent, url string) string {
370 m := "For more information and troubleshooting, see " + url

Callers 3

waitForConnectionMethod · 0.95
handleConnectedMethod · 0.95
waitForReconnectionMethod · 0.95

Calls 2

ErrMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected