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

chore: Transformation.identity vs empty #967

Merged
merged 3 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -39,9 +39,10 @@ import com.google.protobuf.timestamp.Timestamp
import io.grpc.Status
import org.slf4j.Logger
import org.slf4j.LoggerFactory

import scala.concurrent.Future

import akka.projection.grpc.producer.scaladsl.EventProducer.Transformation

/**
* INTERNAL API
*/
Expand Down Expand Up @@ -78,6 +79,10 @@ import scala.concurrent.Future
eventsBySlicesPerStreamId.contains(s.streamId) ||
eventsBySlicesStartingFromSnapshotsPerStreamId.contains(s.streamId),
s"No events by slices query defined for stream id [${s.streamId}]")
require(
s.transformation ne Transformation.empty,
s"Transformation is not defined for stream id [${s.streamId}]. " +
"Use Transformation.identity to pass through each event as is.")
}

private val protoAnySerialization = new ProtoAnySerialization(system)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ object EventProducer {
val empty: Transformation = new Transformation(
mappers = Map.empty,
orElse = envelope =>
Future.failed(new IllegalArgumentException(s"Missing transformation for event [${envelope.event.getClass}]")))
Future.failed(
new IllegalArgumentException(
s"Missing transformation for event [${envelope.event.getClass}]. " +
"Use Transformation.identity to pass through each event as is.")))
johanandren marked this conversation as resolved.
Show resolved Hide resolved

/**
* No transformation. Pass through each event as is.
Expand Down
2 changes: 2 additions & 0 deletions docs/src/main/paradox/grpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ Java

To omit an event the transformation function can return @scala[`None`]@java[`Optional.empty()`].

Use @scala[`Transformation.identity`]@java[`Transformation.identity()`] to pass through each event as is.

That `EventProducer` service is started in an Akka gRPC server like this:

Scala
Expand Down