-
Notifications
You must be signed in to change notification settings - Fork 20
feat: add waitForAgentReady helper for agent deployment polling #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add waitForAgentReady helper for agent deployment polling #9
Conversation
bbatha
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a solid implementation. However please implement it closer to the style of this repo. The #8 is a good reference.
That means that this should be a method on the Agent client class so that it can be used in a fluent style.
src/lib/agent-poll.ts
Outdated
| /** Optional callback for progress updates */ | ||
| onUpdate?: (status: AgentStatus, elapsed: number) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop this
src/lib/agent-poll.ts
Outdated
| | 'STATUS_UNDEPLOYMENT_FAILED' | ||
| | 'STATUS_DELETED'; | ||
|
|
||
| export interface WaitForAgentOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include the request options
src/lib/agent-poll.ts
Outdated
| @@ -0,0 +1,91 @@ | |||
| import Gradient from "@digitalocean/gradient"; | |||
|
|
|||
| export type AgentStatus = | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should already be defined in the agent file
- Converted waitForAgentReady to a method on Agent client for fluent usage - Removed optional onUpdate callback as per review - Reuse existing AgentStatus type from agents.ts - Include request options when calling retrieve() API - Updated sleep helper usage for polling interval Resolves digitalocean#4
|
This looks great can you just make sure lints and tests pass then I'll merge it |
|
Resolves #4 |
The helper does interval based polling for checking agent rediness.
This is needed to avoid running tight loops & respect API rate limits
Example
Edge Cases Handled
AbortSignalfor canceling long-running pollsSTATUS_FAILED,STATUS_UNDEPLOYMENT_FAILED) and throws structured errorsAgentTimeoutErrorandAgentDeploymentErrorclasses enable type-safe error handling with accessible metadataonUpdatecallback provides real-time status updates for UI/logging integration