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
Add Ability to pass own client in AsyncHttpClient so that it's state can be referenced #3859
Conversation
def getTotalConnectionCount: F[Long] = F.delay(underlying.getTotalConnectionCount) | ||
def getTotalActiveConnectionCount: F[Long] = F.delay(underlying.getTotalActiveConnectionCount) | ||
def getTotalIdleConnectionCount: F[Long] = F.delay(underlying.getTotalIdleConnectionCount) | ||
def getStatsPerHost: F[mutable.Map[String, HostStats]] = |
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.
Could we return an immutable map here?
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.
Done!
override def remove(pred: java.util.function.Predicate[Cookie]): Boolean = false | ||
override def clear(): Boolean = false | ||
} | ||
|
||
final case class AsyncHttpClientStats[F[_]: Sync](private val underlying: ClientStats)(implicit |
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.
I don't think I'd make this a case class. There is no meaningful equals, toString, etc, and it's not exactly a product type.
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.
Makes sense, I've made it a simple class
override def remove(pred: java.util.function.Predicate[Cookie]): Boolean = false | ||
override def clear(): Boolean = false | ||
} | ||
|
||
final case class AsyncHttpClientStats[F[_]: Sync](private val underlying: ClientStats)(implicit |
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.
I'd put this class in its own source file.
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.
Moved to it's own file
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.
Test failure is unrelated. This looks great!
Thanks for reviewing it @rossabaker! I can't merge it though since I don't have write access to the repository |
We usually aim for two reviewers, but sometimes our reviewers get busy. I'll go ahead and merge it, and aim to release it this week. |
Currently there is no way to access
org.asynchttpclient.DefaultAsyncHttpClient#getClientStat
when we create aResource[F, Client[F]]
usingorg.http4s.client.asynchttpclient.AsyncHttpClient#resource
.This PR adds an additional apply method in
AsyncHttpClient
which lets the user pass in their ownDefaultAsyncHttpClient
so that they can have a handle on its state and use it for metrics etc.