-
Notifications
You must be signed in to change notification settings - Fork 98
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(pci-kubernetes): streams listing #12613
Conversation
4de922a
to
eb38229
Compare
7c867bf
to
729fcc6
Compare
export const pollOperation = async ( | ||
serviceName: string, | ||
operationId: string, | ||
intervalMs = 1000, | ||
) => { | ||
const poll = async () => { | ||
const { data: op } = await v6.get( | ||
`/dbaas/logs/${serviceName}/operation/${operationId}`, | ||
); | ||
if (op.state === 'SUCCESS') { | ||
return op; | ||
} | ||
if (op.state === 'ERROR') { | ||
throw new Error(op); | ||
} | ||
await new Promise((resolve) => setTimeout(resolve, intervalMs)); | ||
return poll(); | ||
}; | ||
return poll(); | ||
}; |
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.
nitpick: Can we use refetchInterval
on useQuery
for polling.
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.
it's a good point and i tried to use useQuery at first but it turned out to be more complicated for a few reason :
- you want to have a conditional refetch interval so you have to define an additional state to handle the operation status
- you need to synchronize the useMutation so the onSuccess / onError is called only once the polling is done
i think it's simpler this way because the polling is done at a lower api level and the creation/deletion call will only be resolved once the operation is complete (which is what you always want) ; you also don't need the cache capabilities offered by react-query
ref: DTCORE-2485 Signed-off-by: Florian Renaut <florian.renaut@corp.ovh.com>
729fcc6
to
0cb5640
Compare
ref: DTCORE-2486 Signed-off-by: Florian Renaut <florian.renaut@corp.ovh.com>
Quality Gate passedIssues Measures |
Description
Add kubernetes streams listing