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

Readside exponential backoff #329

Closed
wants to merge 8 commits into from
Closed

Readside exponential backoff #329

wants to merge 8 commits into from

Conversation

AntonioYuen
Copy link
Contributor

@AntonioYuen AntonioYuen commented May 3, 2021

Builds on the comments from #322

  • Leverages the retry package for exponential backoff
  • readsidehandler.process() now returns a Future[Boolean] instead of a Boolean.
  • readsidehandlers have their own pool

@AntonioYuen AntonioYuen linked an issue May 3, 2021 that may be closed by this pull request
* @param meta the additional meta data
* @return Boolean for success
*/
protected def doProcessEvent(
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this on the trait? this is an implementation detail

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wanted to decouple the implementation of "process" with the exponential backoff.

eventTag: String,
resultingState: com.google.protobuf.any.Any,
meta: MetaData,
policy: Option[retry.Policy] = Some(retry.Directly()),
Copy link
Contributor

Choose a reason for hiding this comment

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

2 comments:

  • policy should be a constructor arg, not a method arg
  • you don't need an Option if you fail over to retry.Backoff, just make that the default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the backoff policy itself is a stateful class. I wanted to decouple the max and min time from the default arg

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But yeah I didn't mean to set this as Some(something) whoops.


implicit val success: retry.Success[Boolean] = retry.Success(x => x)

val finalPolicy: retry.Policy =
Copy link
Contributor

Choose a reason for hiding this comment

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

this implementation only makes sense for gRPC. Just put it in the impl class.

FYI - this trait was only meant to make testing easier, not really for implementing many of these.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The policy is not a grpc concept though. It is a retry concept.

import scala.concurrent.ExecutionContext

trait ExecutionContextHelper {
implicit val ec: ExecutionContext = ExecutionContext.global
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't do this, just have your test set it explicitly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just felt this was cleaner

@AntonioYuen AntonioYuen marked this pull request as draft May 5, 2021 23:30
@zenyui
Copy link
Contributor

zenyui commented May 9, 2021

@AntonioYuen closing this for now

@zenyui zenyui closed this May 9, 2021
@Tochemey Tochemey deleted the grpc_retry_v2 branch August 25, 2021 12:22
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.

Exponential backoff for projections
3 participants