You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by md...@apache.org on 2023/01/05 08:21:30 UTC
[incubator-pekko-connectors] branch main updated: Update PartialFunction to workaround scalafmt limitation
This is an automated email from the ASF dual-hosted git repository.
mdedetrich pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-pekko-connectors.git
The following commit(s) were added to refs/heads/main by this push:
new 961baf32 Update PartialFunction to workaround scalafmt limitation
961baf32 is described below
commit 961baf32fed60979f0006220d75e498a635286af
Author: Sean Glover <se...@seanglover.com>
AuthorDate: Thu Jan 5 03:21:26 2023 -0500
Update PartialFunction to workaround scalafmt limitation
---
.../googlecloud/storage/impl/GCStorageStream.scala | 26 +++++++++++++---------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/google-cloud-storage/src/main/scala/akka/stream/alpakka/googlecloud/storage/impl/GCStorageStream.scala b/google-cloud-storage/src/main/scala/akka/stream/alpakka/googlecloud/storage/impl/GCStorageStream.scala
index c17861a2..6cfe79bb 100644
--- a/google-cloud-storage/src/main/scala/akka/stream/alpakka/googlecloud/storage/impl/GCStorageStream.scala
+++ b/google-cloud-storage/src/main/scala/akka/stream/alpakka/googlecloud/storage/impl/GCStorageStream.scala
@@ -146,17 +146,21 @@ import scala.concurrent.Future
metadata.fold(HttpEntity.Empty)(m => HttpEntity(ContentTypes.`application/json`, m.toJson.toString))
val request = HttpRequest(POST, uri, headers, entity)
- implicit val um: Unmarshaller[HttpResponse, StorageObject] = Unmarshaller.withMaterializer {
- implicit ec => implicit mat =>
- {
- case HttpResponse(status, _, entity, _) if status.isSuccess() =>
- Unmarshal(entity).to[StorageObject]
- case HttpResponse(status, _, entity, _) =>
- Unmarshal(entity).to[String].flatMap { errorString =>
- Future.failed(new RuntimeException(s"Uploading part failed with status $status: $errorString"))
- }
- }: PartialFunction[HttpResponse, Future[StorageObject]]
- }.withDefaultRetry
+ implicit val um: Unmarshaller[HttpResponse, StorageObject] =
+ Unmarshaller
+ .withMaterializer[HttpResponse, StorageObject] { implicit ec => implicit mat => response =>
+ {
+ val status = response.status
+ val entity = response.entity
+ if (status.isSuccess())
+ Unmarshal(entity).to[StorageObject]
+ else
+ Unmarshal(entity).to[String].flatMap[StorageObject] { errorString =>
+ Future.failed(new RuntimeException(s"Uploading part failed with status $status: $errorString"))
+ }
+ }
+ }
+ .withDefaultRetry
ResumableUpload[StorageObject](request).addAttributes(GoogleAttributes.settings(settings))
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org