Skip to content
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

fix(retry): copy retry middleware to SDK and fix it #114

Merged
merged 1 commit into from
Feb 14, 2023

Conversation

nikolaymatrosov
Copy link
Contributor

As retry middleware from nice-grpc-client-middleware-retry package highly relates to the way stubs are generated, I had to copy it and fix the destructuring issue.

The original middleware presumes that ts-proto is used with --ts_proto_opt=outputServices=generic-definitions option, that add options property object to the method, so it could be later successfully destructured.

closes #113

* Client middleware that adds automatic retries to unary calls.
*/
export const retryMiddleware: ClientMiddleware<RetryOptions> = async function* retryMiddleware(call, options) {
const { idempotencyLevel } = call.method.options ?? {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут же вопрос только в этой строчке? Давай законтрибьютим в nice-grpc-client-middleware-retry и воткнем сюда ссылку на PR с TODO: use nice-grpc-client-middleware-retry from npm?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

По сути да. Сделаю PR. Не знаю, примут ли его, но попробовать стоит.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не вижу причин его не принятия, ведь это просто фоллбэк)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DavyJohnes Как я и опасался, ПР не спешат принимать, предлагая внести исправления глубже по стеку инструментов в генератор ts_proto.
Альтернативным решением может быть реализация ретраев на основе нативного подхода в @grpc/grpc-js, где начиная с версии 1.8.0 появилась реализация RFC по ретраям.

Copy link
Contributor

@DavyJohnes DavyJohnes Feb 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Альтернативным решением может быть реализация ретраев на основе нативного подхода в @grpc/grpc-js, где начиная с версии 1.8.0 появилась реализация RFC по ретраям.

Звучит отлично.

@DavyJohnes DavyJohnes merged commit d244ac1 into yandex-cloud:master Feb 14, 2023
@yandex-cloud-bot
Copy link
Collaborator

🎉 This PR is included in version 2.4.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: Cannot destructure property 'idempotencyLevel' of 'call.method.options' as it is undefined.
3 participants