Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package taglessfinal
- import external.GoogleLocation
- import scala.concurrent.Future
- /**
- * @author Alexander Isakov
- */
- trait GoogleLocationService[F[_]] {
- def getByAddress(address: String): F[GoogleLocation]
- }
- sealed trait GoogleLocationServiceError
- case object ConnectionError extends GoogleLocationServiceError
- case object GoogleLocationNotFoundError extends GoogleLocationServiceError
- object GoogleLocationService {
- type DefaultResult[A] = Future[Either[GoogleLocationServiceError, A]]
- val defaultGoogleLocationService = new GoogleLocationService[DefaultResult] {
- def getByAddress(address: String): DefaultResult[GoogleLocation] = ???
- }
- //
- type LocationServiceResult[A] = Future[Either[LocationError, A]]
- val defaultGoogleLocationServiceForLocationService = new GoogleLocationService[LocationServiceResult] {
- def getByAddress(address: String): LocationServiceResult[GoogleLocation] = {
- defaultGoogleLocationService
- .getByAddress(address)
- .map(_.left.map {
- case ConnectionError => RetryLaterError
- case GoogleLocationNotFoundError => InvalidLocationArgumentsError
- })
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement