Skip to content

Adding middleware call in host queue writes #4337

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

Open
wants to merge 45 commits into
base: circuit_breaker_middleware
Choose a base branch
from

Conversation

ggaurav08
Copy link

@ggaurav08 ggaurav08 commented Apr 25, 2025

What this PR does / why we need it:
This PR uses circuit breaker middleware in M3DB client write calls.

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing and/or backwards incompatible change?:

NONE

Does this PR require updating code package or user-facing documentation?:

NONE

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@@ -674,7 +677,7 @@ func (q *queue) asyncWrite(
}

ctx, _ := thrift.NewContext(q.opts.WriteRequestTimeout())
err = client.WriteBatchRaw(ctx, req)
err = q.middleware(client).WriteBatchRaw(ctx, req)
Copy link
Collaborator

Choose a reason for hiding this comment

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

simplify this middleware wrapping to be done at construction time, instead of each request

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I have updated it.

@@ -92,6 +93,29 @@ func newHostQueue(
iOpts = iOpts.SetMetricsScope(scope)
opts = opts.SetInstrumentOptions(iOpts.SetMetricsScope(scope))

// Create circuit breaker middleware
cbMiddleware, err := middleware.New(
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you want to add support for a no-op middleware somehow?

Copy link
Author

Choose a reason for hiding this comment

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

Added it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

you added the type but it's not used anywhere. should we do something like if circuitbreaker not enabled use the noop else current path?

Copy link
Collaborator

@prateek prateek left a comment

Choose a reason for hiding this comment

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

please add unit + integration tests for this

@ggaurav08 ggaurav08 marked this pull request as ready for review May 23, 2025 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy