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

Remove some unsafeRunSync calls #648

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ object RateLimitingBackend {
def apply[S](
delegate: SttpBackend[IO, S],
maxParallelRequests: Int
)(implicit ioRuntime: IORuntime): RateLimitingBackend[IO, S] =
new RateLimitingBackend[IO, S](
)(implicit ioRuntime: IORuntime): IO[RateLimitingBackend[IO, S]] =
for {
sem <- Semaphore[IO](maxParallelRequests.toLong)
} yield new RateLimitingBackend[IO, S](
delegate,
Semaphore[IO](maxParallelRequests.toLong).unsafeRunSync()
sem
)

def apply[F[_], S](
Expand Down
15 changes: 6 additions & 9 deletions src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,12 @@ class ClientTest extends SdkTestSpec with OptionValues {
}

it should "support client with RateLimitingBackend" in {
GenericClient[IO](
"scala-sdk-test",
projectName,
baseUrl,
auth
)(
implicitly,
RateLimitingBackend[Any](AsyncHttpClientCatsBackend[IO]().unsafeRunSync(), 5)
).token.inspect().unsafeRunSync().projects should not be empty
for {
httpBackend <- AsyncHttpClientCatsBackend[IO]()
rateLimiting <- RateLimitingBackend[Any](httpBackend, 5)
client = GenericClient[IO]("scala-sdk-test", projectName, baseUrl, auth)(implicitly, rateLimiting)
token <- client.token.inspect()
} yield (token.projects should not be empty
}

it should "support client with BackpressureThrottleBackend" in {
Expand Down