Skip to content

Commit

Permalink
gRPC should not use base-64 encoding/decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandrohdezma committed Jun 25, 2024
1 parent 6f83c1d commit a21379c
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package fs2.pubsub.grpc

import java.util.Base64

import cats.effect.Temporal
import cats.syntax.all._

Expand Down Expand Up @@ -114,7 +112,7 @@ object GrpcConstructors {
): F[List[MessageId]] = {
val toPubSubMessage = (record: PubSubRecord.Publisher[A]) =>
PubsubMessage(
data = ByteString.copyFromUtf8(Base64.getEncoder().encodeToString(MessageEncoder[A].encode(record.data))),
data = ByteString.copyFrom(MessageEncoder[A].encode(record.data)),
attributes = record.attributes
)

Expand All @@ -140,7 +138,7 @@ object GrpcConstructors {

val toPubSubRecord = (message: ReceivedMessage) =>
PubSubRecord.Subscriber(
message.message.map(m => m.data.toByteArray()).map(Base64.getDecoder().decode),
message.message.map(m => m.data.toByteArray()),
message.message.map(_.attributes).orEmpty,
message.message.map(_.messageId).map(MessageId(_)),
message.message.flatMap(_.publishTime.map(_.asJavaInstant)),
Expand Down

0 comments on commit a21379c

Please sign in to comment.