-
Notifications
You must be signed in to change notification settings - Fork 4
CORE-308 Use okhttp rite #1570
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
CORE-308 Use okhttp rite #1570
Conversation
|
||
private def newApiClient(user: WithAccessToken) = { | ||
val apiClient = new ApiClient() | ||
val apiClient = new ApiClient(httpClient) |
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.
This is the important change. httpClient
is reused across all sam calls using the client library
dispatcher.setMaxRequests(1000) | ||
dispatcher.setMaxRequestsPerHost(100) |
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 am just guessing here. I will circle back to make these configurable if this ends up helping
implicit val executionContext: ExecutionContext | ||
implicit val materializer: Materializer | ||
|
||
val samDao: SamDAO |
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.
changes in this file are related to moving the getUserStatusInfo
call to samDAO
|
||
implicit override val executionContext: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global | ||
|
||
val samDao: SamDAO = mock[SamDAO](RETURNS_SMART_NULLS) |
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.
can use mockito now instead of a mock http server
https://broadworkbench.atlassian.net/browse/CORE-308
An observation from the logs is that for orch, the connect timeouts only occur using Sam's client library. Orch only uses sam client library for 2 calls,
getUserStatusInfo
andbulkMembershipUpdateV2
. All other calls use a hand rolled client using akka http. Granted,getUserStatusInfo
is called on every api call so the prevalence of the error might be biased towards that call.The crux of this change is to use a shared instance of the okhttp client configured for large bandwidth to sam. As it was, each new
ApiClient
was creating a bunch of resources for single use that were meant to be reused. This will hopefully lead to fewer connection attempts and fewer timeouts.An ancillary change is to move a call to sam into the SamDAO (I don't know why it wasn't there to start... probably plumbing issues).
Have you read CONTRIBUTING.md lately? If not, do that first.
I, the developer opening this PR, do solemnly pinky swear that:
In all cases: