-
-
Notifications
You must be signed in to change notification settings - Fork 757
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
Requests retries #1537
Comments
@dryna You can try to use const skippable = (hookName, hookFunc) => {
return context => {
if (context.params.skipHooks) {
const { type } = context;
const { skipHooks } = context.params;
if (
skipHooks.includes(hookName) ||
skipHooks.includes('all') ||
(skipHooks.includes('before') && type === 'before') ||
(skipHooks.includes('after') && type === 'after')
) {
return context;
} else {
return hookFunc(context);
}
} else {
return hookFunc(context);
}
};
}; This requires that you wrap your hook declarations such as const myHook = skippable('myHook', context => {
// do stuff her
}); Then you can call the service again in the error hook like so // this is super basic and would require more attention to what methog to call, etc
// this is just showing how to pass skipHooks
const result = await context.service.get(context.id, { ...context.params, skipHooks: ['all'] }) I am not sure you really could skip all hooks. Many feathers plugins, such as |
Came across this while looking for My request is, rather than provisioning options for developers to somehow achieve retries, it would be great if the framework abstracts it out and provides built-in retries as the natural way of any service call. For example, currently we get Similar to hooks, if It would take away one big headache for the dev in designing the components. Currently we have to carefully tag every service call with catch handlers and do unpleasant code juggles to retry the call for certain number of tries before failing, not so elegant and unnecessarily repeated code. |
Also, in a micro-services scenario with complex dependencies amongst services, retries could prove to be helpful for self-regulating services (auto switch-on and shutdown), as noted here #853 |
It's more of a feature request to feathers-client rather than an issue. Currently, in my project, I'm trying to repeat requests when the request times out or gets rate-limited. I can't find an easy way to handle it globally in feathers.
I was thinking about doing in on the error hook, however, there is an issue on how to repeat request. When I send a request using feathers-client, it will fire all hooks (in the client) again and we don't want that (I would need to set some flag to skip all hooks).
For now, only option that I've found is for sockets transport to overload emit method.
Is there a possibility to add some middleware or some hook to feathers client that would allow to retry requests? Or maybe already there is a better method to achieve request repeats?
The text was updated successfully, but these errors were encountered: