Created
December 3, 2016 17:33
-
-
Save aiacovella/a315cd49fa9aa3e02bb0d469692769c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CQRSContext( | |
outgoingWireRepo: BusinessExceptionsOutgoingWireRepoT, | |
persistenceOffsetRepo: PersistenceOffsetRepoT, | |
settings: Settings, | |
exceptionsActorSystem: ActorSystem | |
)(implicit ec: ExecutionContext) extends LazyLogging { | |
val configuration = new BusinessExceptionsConfiguration() | |
val exceptionsBackEnd = new AkkaBackend { | |
val actorSystem = exceptionsActorSystem | |
def sourceProvider(query: Query): EventsSourceProvider = new EventsSourceProvider { | |
override def source(offset: Long)(implicit context: ActorContext) = { | |
logger.error("Empty source provider has been called by the exceptions backend. This should not be used.") | |
Source.empty | |
} | |
} | |
}.configure( | |
aggregate[BusinessExceptionsAggregate](configuration.behavior) | |
) | |
val evaluatorSupervisor = exceptionsActorSystem.actorOf(ExceptionsEvaluatorSupervisor.props( | |
settings, | |
new EvaluationService, | |
new ExceptionsService(exceptionsBackEnd) | |
)) | |
val wireBackEnd = new AkkaBackend { | |
val actorSystem = exceptionsActorSystem | |
def sourceProvider(query: Query): EventsSourceProvider = { | |
query match { | |
case QueryByTag(tag) => | |
logger.debug(s"Querying by tag: $tag") | |
new CassandraEventSourceProvider(tag, "wire-query-journal") | |
} | |
} | |
}.configure( | |
ProjectionConfig( | |
query = QueryByTag(EventTags.OutgoingWiresTag), | |
projection = new BusinessExceptionsOutgoingWireProjection( | |
outgoingWireRepo, evaluatorSupervisor, settings | |
), | |
name = "BusinessExceptionOutgoingWireProjection" | |
).withCustomOffsetPersistence(new JDBCOffsetPersistenceStrategy(persistenceOffsetRepo, "BusinessExceptionsOutgoingWire") | |
) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment