codacy.events.DefaultEventComponents.scala Maven / Gradle / Ivy
package codacy.events
import akka.actor.ActorSystem
import codacy.events.internal.EventActorSystem
import scala.concurrent.Future
import scala.util.Try
import com.spingo.op_rabbit.ConnectionParams
trait DefaultEventComponents
extends EventBus.Components
with codacy.events.AsyncRabbitControl.Components
with ConnectionParamsComponents[Future] {
def actorSystem: ActorSystem
override def eventActorSystem: EventActorSystem = EventActorSystem(actorSystem)
override lazy val connectionParams =
Future.fromTry(Try(ConnectionParams.fromConfig()))
}
trait DefaultEventConsumerComponents
extends DefaultEventComponents
with InitEventQueue.Components
with Topic.Components[Future] { self: ComponentName.Components[Future] =>
def eventRouter: EventRouter
override lazy val removeTopics = eventRouter.removeTopics
override lazy val topics =
Future.successful(eventRouter.usedTopics.toSet.map((raw: String) => Topic(raw.split('.').map(TopicPart(_)).toList)))
lazy val eventConsumer = EventConsumer.defaultEventConsumer(
InitEventQueue.initEventQueueFromRabbitControl(asyncRabbitControl, self, eventRouter.removeTopics, self),
eventRouter,
asyncRabbitControl,
self,
eventActorSystem
)(eventLogger)
}