Skip to content
Merged
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 @@ -57,6 +57,8 @@ final class ActionsImpl(_system: ActorSystem, services: Map[String, ActionServic
private object creationContext extends ActionCreationContext {
override def serviceCallFactory(): ServiceCallFactory = rootContext.serviceCallFactory()
}
private val actionHandlers: Map[String, ActionHandler] =
services.view.mapValues(_.factory.create(creationContext)).toMap

private def toJavaPbAny(any: Option[ScalaPbAny]) =
any.fold(JavaPbAny.getDefaultInstance)(ScalaPbAny.toJavaProto)
Expand All @@ -82,11 +84,10 @@ final class ActionsImpl(_system: ActorSystem, services: Map[String, ActionServic
* side effects.
*/
override def handleUnary(in: ActionCommand): Future[ActionResponse] =
services.get(in.serviceName) match {
case Some(service) =>
actionHandlers.get(in.serviceName) match {
case Some(handler) =>
val context = createContext(in)
service.factory
.create(creationContext)
handler
.handleUnary(in.name, MessageEnvelope.of(toJavaPbAny(in.payload), context.metadata()), context)
.toScala
.map(replyToActionResponse)
Expand Down