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

Cleanup ExplorerApiClient and ApiClient, share OkHttp instance #156

Merged
merged 1 commit into from
Apr 7, 2022

Conversation

MrStahlfelge
Copy link
Member

This cleans up ExplorerApiClient from a lot of unreachable code, and some code smells in ApiClient when using a proxy.

NodeAndExplorerDataSourceImpl shares its OkHttpClient between both ApiClient and ExplorerApiClient, as it is strongly advised to use OkHttpClient as a singleton (see OkHttpClient documentation). So instead of two new instances we only use one this way.

To get this even better, it should be possible to set the OkHttpClient to be used by RestApiErgoClient so that not a new one has to be spin up for every instantiation of it. I think the current proxy param of RestApiErgoClient should be replaced by a OkHttpClientBuilder param as this lets clients set proxy and many more settings like timeout etc. I just wanted to ask you on your opinion @aslesarenko because this means leaking implementation details to the clients, but this has strong technical reasons and is done by Retrofit for the same reason.

@aslesarenko
Copy link
Member

@MrStahlfelge I completely agree with making singleton and suggested refactorings as long as interfaces are free from implementation details.

… OkHttpClient instance and way to use OkHttpClientBuilder instance from client
@MrStahlfelge
Copy link
Member Author

Great that made it easier!

Ping to @anon2020s since he added the proxy param

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.

2 participants