-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
StacClient supports pagination and has fs2.Streams in the interface
- Loading branch information
Showing
9 changed files
with
143 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
modules/client/js/src/main/scala/com/azavea/stac4s/api/client/SttpStacClient.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package com.azavea.stac4s.api.client | ||
|
||
import cats.MonadError | ||
import cats.MonadThrow | ||
import sttp.client3.SttpBackend | ||
import sttp.model.Uri | ||
|
||
object SttpStacClient { | ||
|
||
def apply[F[_]: MonadError[*[_], Throwable]](client: SttpBackend[F, Any], baseUri: Uri): SttpStacClient[F] = | ||
def apply[F[_]: MonadThrow](client: SttpBackend[F, Any], baseUri: Uri): SttpStacClient[F] = | ||
SttpStacClientF[F, SearchFilters](client, baseUri) | ||
} |
4 changes: 2 additions & 2 deletions
4
modules/client/jvm/src/main/scala/com/azavea/stac4s/api/client/SttpStacClient.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package com.azavea.stac4s.api.client | ||
|
||
import cats.MonadError | ||
import cats.MonadThrow | ||
import sttp.client3.SttpBackend | ||
import sttp.model.Uri | ||
|
||
object SttpStacClient { | ||
|
||
def apply[F[_]: MonadError[*[_], Throwable]](client: SttpBackend[F, Any], baseUri: Uri): SttpStacClient[F] = | ||
def apply[F[_]: MonadThrow](client: SttpBackend[F, Any], baseUri: Uri): SttpStacClient[F] = | ||
SttpStacClientF[F, SearchFilters](client, baseUri) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
modules/client/shared/src/test/scala/com/azavea/stac4s/api/client/SttpEitherInstances.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.azavea.stac4s.api.client | ||
|
||
import cats.effect.{ExitCase, Sync} | ||
|
||
trait SttpEitherInstances { | ||
|
||
/** [[Sync]] instance defined for Either[Throwable, *]. | ||
* It is required (sadly) to derive [[fs2.Stream.Compiler]] which is necessary for the [[fs2.Stream.compile]] function. | ||
*/ | ||
implicit val eitherSync: Sync[Either[Throwable, *]] = new Sync[Either[Throwable, *]] { | ||
lazy val me = cats.instances.either.catsStdInstancesForEither[Throwable] | ||
|
||
def suspend[A](thunk: => Either[Throwable, A]): Either[Throwable, A] = thunk | ||
|
||
def bracketCase[A, B](acquire: Either[Throwable, A])(use: A => Either[Throwable, B])( | ||
release: (A, ExitCase[Throwable]) => Either[Throwable, Unit] | ||
): Either[Throwable, B] = | ||
flatMap(acquire)(use) | ||
|
||
def flatMap[A, B](fa: Either[Throwable, A])(f: A => Either[Throwable, B]): Either[Throwable, B] = | ||
fa.flatMap(f) | ||
|
||
def tailRecM[A, B](a: A)(f: A => Either[Throwable, Either[A, B]]): Either[Throwable, B] = | ||
me.tailRecM(a)(f) | ||
|
||
def raiseError[A](e: Throwable): Either[Throwable, A] = me.raiseError(e) | ||
|
||
def handleErrorWith[A](fa: Either[Throwable, A])(f: Throwable => Either[Throwable, A]): Either[Throwable, A] = | ||
me.handleErrorWith(fa)(f) | ||
|
||
def pure[A](x: A): Either[Throwable, A] = me.pure(x) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.