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

Split client into client and transport (preelminary PR for Dark Sky integration) #74

Merged
merged 1 commit into from
Jul 12, 2018

Conversation

asoltysik
Copy link
Contributor

@asoltysik asoltysik commented Jul 12, 2018

Due to moving and splitting files around, git diff was not too kind to us, hence this PR. Could not make it smaller though.

Most important changes:

  • constructing the clients is now only possible through functions in providers.openweather.OpenWeatherMap object, constructors of these clients are package-private. This is also important because of possible changes comming with Split OWM API or make it more explicit about valid URLs #64
  • API-agnostic Transport was split from the Client. It's similar to transport in 0.3, but contains everything needed for decoding (where transport in 0.3 returned jsons)
  • Timeout functionality from the caching client was also moved out to TimeoutHttpTransport

@asoltysik asoltysik requested a review from BenFradet July 12, 2018 08:37
Copy link
Contributor

@BenFradet BenFradet left a comment

Choose a reason for hiding this comment

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

Looks good I just have a few questions regarding the api surface area

* Create `OwmClient` with specified underlying `Transport`
* @param transport instance of `Transport` which will do the actual sending of data
*/
def basicClient[F[_]: Sync](transport: Transport[F]): OwmClient[F] =
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should expose this one?

* geoPrecision 1 will give ~60km infelicity if worst case; 2 ~30km etc
* @param transport instance of `Transport` which will do the actual sending of data
*/
def cacheClient[F[_]: Concurrent](cacheSize: Int, geoPrecision: Int, transport: Transport[F]): F[OwmCacheClient[F]] =
Copy link
Contributor

Choose a reason for hiding this comment

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

same here?

*/
case class OwmClient[F[_]: Sync](appId: String, apiHost: String = "api.openweathermap.org", ssl: Boolean = false)
extends Client[F] {
class OwmClient[F[_]] private[openweather] (private[openweather] val transport: Transport[F]) {
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 transport private[openweather] and not just simply private?

@asoltysik
Copy link
Contributor Author

@BenFradet done

Copy link
Contributor

@BenFradet BenFradet left a comment

Choose a reason for hiding this comment

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

LGTM 👍 merging when green

@codecov-io
Copy link

Codecov Report

Merging #74 into develop will decrease coverage by 2.8%.
The diff coverage is 62.5%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #74      +/-   ##
===========================================
- Coverage     78.4%   75.59%   -2.81%     
===========================================
  Files            9       11       +2     
  Lines          125      127       +2     
  Branches         2        2              
===========================================
- Hits            98       96       -2     
- Misses          27       31       +4
Impacted Files Coverage Δ
...tics/weather/providers/openweather/Responses.scala 95% <ø> (ø) ⬆️
...n/scala/com.snowplowanalytics/weather/Errors.scala 100% <ø> (ø)
...weather/providers/openweather/OwmCacheClient.scala 91.66% <ø> (+0.75%) ⬆️
...ytics/weather/providers/openweather/Requests.scala 71.42% <ø> (ø) ⬆️
...weather/providers/openweather/OpenWeatherMap.scala 100% <100%> (ø)
...owplowanalytics/weather/TimeoutHttpTransport.scala 20% <20%> (ø)
...tics/weather/providers/openweather/OwmClient.scala 45.16% <45.16%> (-38.18%) ⬇️
.../com.snowplowanalytics/weather/HttpTransport.scala 86.36% <86.36%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c225fa1...21c4d02. Read the comment docs.

@BenFradet BenFradet merged commit b0ff33f into develop Jul 12, 2018
@BenFradet BenFradet deleted the split-client branch July 12, 2018 11:16
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