本文整理汇总了Scala中com.lightbend.lagom.scaladsl.persistence.AggregateEvent类的典型用法代码示例。如果您正苦于以下问题:Scala AggregateEvent类的具体用法?Scala AggregateEvent怎么用?Scala AggregateEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AggregateEvent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: ReadSideTestDriver
//设置package包名称以及导入依赖的类
package sample.helloworldconsumer.impl
import akka.Done
import akka.persistence.query.Offset
import akka.stream.Materializer
import akka.stream.scaladsl.{Sink, Source}
import com.lightbend.lagom.scaladsl.persistence.ReadSideProcessor.ReadSideHandler
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, EventStreamElement, ReadSide, ReadSideProcessor}
import scala.concurrent.{ExecutionContext, Future}
class ReadSideTestDriver(implicit val materializer: Materializer, ec: ExecutionContext) extends ReadSide {
private var processors = Map.empty[Class[_], Seq[Future[(ReadSideHandler[_], Offset)]]]
override def register[Event <: AggregateEvent[Event]](processorFactory: => ReadSideProcessor[Event]): Unit = {
val processor = processorFactory
val eventTags = processor.aggregateTags
val handler = processor.buildHandler()
val future = for {
_ <- handler.globalPrepare()
offset <- handler.prepare(eventTags.head)
} yield {
handler -> offset
}
synchronized {
val handlers = processors.getOrElse(eventTags.head.eventType, Nil)
processors += (eventTags.head.eventType -> (handlers :+ future))
}
}
def feed[Event <: AggregateEvent[Event]](entityId: String, event: Event, offset: Offset): Future[Done] = {
processors.get(event.aggregateTag.eventType) match {
case None => sys.error(s"No processor registered for Event ${event.aggregateTag.eventType.getCanonicalName}")
case Some(handlerFutures) =>
for {
handlers <- Future.sequence(handlerFutures)
_ <- Future.sequence(handlers.map {
case (handler: ReadSideHandler[Event], _) =>
Source.single(new EventStreamElement(entityId, event, offset))
.via(handler.handle())
.runWith(Sink.ignore)
})
} yield {
Done
}
}
}
}
开发者ID:knoldus,项目名称:lagom-scala-wordcount.g8,代码行数:52,代码来源:ReadSideTestDriver.scala
示例2: BasketEntityFormats
//设置package包名称以及导入依赖的类
package demo.impl.basket
import akka.{Done, NotUsed}
import com.lightbend.lagom.scaladsl.persistence.PersistentEntity.ReplyType
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, AggregateEventTag, PersistentEntity}
import com.lightbend.lagom.scaladsl.playjson.JsonSerializer
import demo.api.basket.{Basket, Item}
import play.api.libs.json.{Format, Json}
object BasketEntityFormats {
implicit val addItemFormat: Format[AddItem] = Json.format
implicit val getBasketFormat: Format[GetBasket.type] = JsonSerializer.emptySingletonFormat(GetBasket)
implicit val itemAddedFormat: Format[ItemAdded] = Json.format
implicit val basketEntityStateFormat: Format[BasketEntityState] = Json.format
}
trait BasketEntityCommand
case class AddItem(item: Item) extends BasketEntityCommand with ReplyType[Done]
case object GetBasket extends BasketEntityCommand with ReplyType[Basket]
case class BasketEntityState(currentBasket: Basket)
object BasketEntityState{
val initial = BasketEntityState(Basket(Seq(), 0))
}
sealed trait BasketEntityEvent extends AggregateEvent[BasketEntityEvent] {
override def aggregateTag = BasketEntityEvent.Tag
}
object BasketEntityEvent {
val Tag = AggregateEventTag.sharded[BasketEntityEvent](4)
}
case class ItemAdded(item: Item) extends BasketEntityEvent
final class BasketEntity extends PersistentEntity {
override type Command = BasketEntityCommand
override type Event = BasketEntityEvent
override type State = BasketEntityState
override def initialState = BasketEntityState.initial
override def behavior: Behavior = {
Actions()
.onCommand[AddItem, Done] {
case (AddItem(item), ctx, state) =>
ctx.thenPersist(ItemAdded(item))(_ => ctx.reply(Done))
}
.onReadOnlyCommand[GetBasket.type, Basket] {
case (GetBasket, ctx, state) => ctx.reply(state.currentBasket)
}
.onEvent {
case (ItemAdded(item), state) => {
val newItems = state.currentBasket.items :+ item
state.copy(Basket(newItems, newItems.map(_.price).sum))
}
}
}
}
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:60,代码来源:BasketEntity.scala
示例3: aggregateTag
//设置package包名称以及导入依赖的类
package com.grossbit.user.impl.persistance.event
import java.util.UUID
import com.grossbit.user.api.ResponseDone
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, AggregateEventTag, AggregateEventTagger}
import play.api.libs.json.{Format, Json}
sealed trait UserEvent extends AggregateEvent[UserEvent]{
override def aggregateTag: AggregateEventTagger[UserEvent] = UserEvent.UserEventTag
}
object UserEvent{
val NumShards=4
val UserEventTag = AggregateEventTag.sharded[UserEvent](NumShards)
}
case class UserCreated(uuid:String,name: String, email: String, password: String) extends UserEvent
case class UserUpdated(uuid:String,name: String, email: String, password: String) extends UserEvent
case class UserDeleted(name: String) extends UserEvent
object UserCreated {
implicit val format: Format[UserCreated] = Json.format
}
object UserUpdated {
implicit val format: Format[UserUpdated] = Json.format
}
object UserDeleted {
implicit val format: Format[UserDeleted] = Json.format
}
开发者ID:sarathraj-coder,项目名称:lagommicroapp,代码行数:32,代码来源:UserEvent.scala
示例4: ReadSideTestDriver
//设置package包名称以及导入依赖的类
package com.example.auction.item.impl
import akka.Done
import akka.persistence.query.Offset
import akka.stream.Materializer
import akka.stream.scaladsl.{Sink, Source}
import com.lightbend.lagom.scaladsl.persistence.ReadSideProcessor.ReadSideHandler
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, EventStreamElement, ReadSide, ReadSideProcessor}
import scala.concurrent.{ExecutionContext, Future}
class ReadSideTestDriver(implicit val materializer: Materializer, ec: ExecutionContext) extends ReadSide {
private var processors = Map.empty[Class[_], Seq[Future[(ReadSideHandler[_], Offset)]]]
override def register[Event <: AggregateEvent[Event]](processorFactory: => ReadSideProcessor[Event]): Unit = {
val processor = processorFactory
val eventTags = processor.aggregateTags
val handler = processor.buildHandler()
val future = for {
_ <- handler.globalPrepare()
offset <- handler.prepare(eventTags.head)
} yield {
handler -> offset
}
synchronized {
val handlers = processors.getOrElse(eventTags.head.eventType, Nil)
processors += (eventTags.head.eventType -> (handlers :+ future))
}
}
def feed[Event <: AggregateEvent[Event]](entityId: String, event: Event, offset: Offset): Future[Done] = {
processors.get(event.aggregateTag.eventType) match {
case None => sys.error(s"No processor registered for Event ${event.aggregateTag.eventType.getCanonicalName}")
case Some(handlerFutures) =>
for {
handlers <- Future.sequence(handlerFutures)
_ <- Future.sequence(handlers.map {
case (handler: ReadSideHandler[Event], _) =>
Source.single(new EventStreamElement(entityId, event, offset))
.via(handler.handle())
.runWith(Sink.ignore)
})
} yield {
Done
}
}
}
}
开发者ID:lagom,项目名称:online-auction-scala,代码行数:50,代码来源:ReadSideTestDriver.scala
示例5: aggregateTag
//设置package包名称以及导入依赖的类
package org.wex.cmsfs.monitor.impl
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, AggregateEventTag}
import org.wex.cmsfs.monitor.api.Monitor
import play.api.libs.json.{Format, Json}
sealed trait MonitorEvent extends AggregateEvent[MonitorEvent] {
override def aggregateTag = MonitorEvent.Tag
}
object MonitorEvent {
val NumShards = 1
val Tag = AggregateEventTag.sharded[MonitorEvent](NumShards)
}
case class MonitorCreated(monitor: Monitor) extends MonitorEvent
object MonitorCreated {
implicit val format: Format[MonitorCreated] = Json.format
}
开发者ID:shinhwazx160,项目名称:test,代码行数:21,代码来源:MonitorEvent.scala
示例6: ExOneService
//设置package包名称以及导入依赖的类
package com.example.exone.api
import com.lightbend.lagom.scaladsl.api.Service
import com.lightbend.lagom.scaladsl.api.broker.Topic
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, AggregateEventTag, AggregateEventTagger}
import play.api.libs.json.{Format, Json}
object ExOneService {
val TOPIC_NAME = "exoneEvents"
}
trait ExOneService extends Service {
def exOneEvents(): Topic[ExOneEvent]
override final def descriptor = {
import Service._
named("exonedocs").withTopics(
topic(ExOneService.TOPIC_NAME, exOneEvents)
).withAutoAcl(true)
}
}
case class ExOneEvent(id:String, value:String) extends AggregateEvent[ExOneEvent]{
override def aggregateTag: AggregateEventTagger[ExOneEvent] = ExOneEvent.Tag
}
object ExOneEvent{
val NumShards = 4
val Tag = AggregateEventTag.sharded[ExOneEvent](4)
implicit val format: Format[ExOneEvent] = Json.format[ExOneEvent]
}
开发者ID:dsugden,项目名称:saga-lagom,代码行数:36,代码来源:ExOneService.scala
示例7: CounterEntity
//设置package包名称以及导入依赖的类
package com.example.counter.impl
import akka.Done
import com.lightbend.lagom.scaladsl.persistence.PersistentEntity.ReplyType
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, AggregateEventTag, PersistentEntity}
import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}
import play.api.libs.json.Json
import scala.collection.immutable.Seq
class CounterEntity extends PersistentEntity {
type Command = CounterCommand[_]
type Event = CounterEvent
type State = CounterState
def initialState = CounterState(0)
def behavior = {
case CounterState(_) => Actions()
.onCommand[Add, Done] { case (Add(x), ctx, _) => ctx.thenPersist(Added(x)) { _ => ctx.reply(Done) } }
.onReadOnlyCommand[GetState.type, Int] { case (GetState, ctx, CounterState(n)) => ctx.reply(n) }
.onEvent { case (Added(x), CounterState(n)) => CounterState(n + x) }
}
}
case class CounterState(n: Int)
object CounterState { implicit val format = Json.format[CounterState] }
sealed trait CounterEvent extends AggregateEvent[CounterEvent] { def aggregateTag = CounterEvent.Tag }
object CounterEvent { val Tag = AggregateEventTag[CounterEvent] }
case class Added(n: Int) extends CounterEvent
object Added { implicit val format = Json.format[Added] }
sealed trait CounterCommand[R] extends ReplyType[R]
case class Add(n: Int) extends CounterCommand[Done]
object Add { implicit val format = Json.format[Add] }
case object GetState extends CounterCommand[Int] { implicit val format = JsonSerializer.emptySingletonFormat(GetState) }
object CounterSerializerRegistry extends JsonSerializerRegistry {
override def serializers: Seq[JsonSerializer[_]] = Seq(
JsonSerializer[Add],
JsonSerializer[Added],
JsonSerializer[CounterState],
JsonSerializer[GetState.type]
)
}
开发者ID:namelos,项目名称:lagom-spike,代码行数:47,代码来源:CounterEntity.scala
示例8: IdentityEvent
//设置package包名称以及导入依赖的类
package io.digitalcat.publictransportation.services.identity.impl
import java.util.UUID
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, AggregateEventShards, AggregateEventTag}
import play.api.libs.json.{Format, Json}
object IdentityEvent {
val NumShards = 5
val Tag = AggregateEventTag.sharded[IdentityEvent]("IdentityEvent", NumShards)
}
sealed trait IdentityEvent extends AggregateEvent[IdentityEvent] {
override def aggregateTag(): AggregateEventShards[IdentityEvent] = IdentityEvent.Tag
}
case class ClientCreated(company: String) extends IdentityEvent
object ClientCreated {
implicit val format: Format[ClientCreated] = Json.format
}
case class UserCreated(userId: UUID, firstName: String, lastName: String, email: String, username: String, hashedPassword: String) extends IdentityEvent
object UserCreated {
implicit val format: Format[UserCreated] = Json.format
}
开发者ID:dpalinic,项目名称:lagom-jwt-authentication,代码行数:26,代码来源:IdentityEvent.scala
示例9: ShardedBlogEventTag
//设置package包名称以及导入依赖的类
package docs.home.scaladsl.persistence
import com.lightbend.lagom.scaladsl.persistence.AggregateEventShards
import com.lightbend.lagom.scaladsl.persistence.AggregateEvent
import com.lightbend.lagom.scaladsl.persistence.AggregateEventTag
class ShardedBlogEventTag {
//#sharded-tags
object BlogEvent {
val NumShards = 20
val Tag = AggregateEventTag.sharded[BlogEvent](NumShards)
}
sealed trait BlogEvent extends AggregateEvent[BlogEvent] {
override def aggregateTag: AggregateEventShards[BlogEvent] = BlogEvent.Tag
}
//#sharded-tags
}
开发者ID:lagom,项目名称:lagom,代码行数:20,代码来源:ShardedBlogEventTag.scala
示例10: BlogEventTag
//设置package包名称以及导入依赖的类
package docs.home.scaladsl.persistence
import com.lightbend.lagom.scaladsl.persistence.AggregateEventShards
import com.lightbend.lagom.scaladsl.persistence.AggregateEvent
import com.lightbend.lagom.scaladsl.persistence.AggregateEventTag
class BlogEventTag {
//#aggregate-tag
object BlogEvent {
val BlogEventTag = AggregateEventTag[BlogEvent]
}
sealed trait BlogEvent extends AggregateEvent[BlogEvent] {
override def aggregateTag: AggregateEventTag[BlogEvent] =
BlogEvent.BlogEventTag
}
//#aggregate-tag
}
开发者ID:lagom,项目名称:lagom,代码行数:20,代码来源:BlogEventTag.scala
示例11: BlogEvent
//设置package包名称以及导入依赖的类
package docs.home.scaladsl.persistence
//#full-example
import com.lightbend.lagom.scaladsl.persistence.AggregateEvent
import com.lightbend.lagom.scaladsl.persistence.AggregateEventShards
import com.lightbend.lagom.scaladsl.persistence.AggregateEventTag
import com.lightbend.lagom.scaladsl.playjson.JsonSerializer
object BlogEvent {
val NumShards = 20
// second param is optional, defaults to the class name
val Tag = AggregateEventTag.sharded[BlogEvent](NumShards)
import play.api.libs.json._
private implicit val postContentFormat = Json.format[PostContent]
val serializers = Vector(
JsonSerializer(Json.format[PostAdded]),
JsonSerializer(Json.format[BodyChanged]),
JsonSerializer(Json.format[PostPublished]))
}
sealed trait BlogEvent extends AggregateEvent[BlogEvent] {
override def aggregateTag: AggregateEventShards[BlogEvent] = BlogEvent.Tag
}
final case class PostAdded(postId: String, content: PostContent) extends BlogEvent
final case class BodyChanged(postId: String, body: String) extends BlogEvent
final case class PostPublished(postId: String) extends BlogEvent
//#full-example
开发者ID:lagom,项目名称:lagom,代码行数:33,代码来源:BlogEvent.scala
示例12: CassandraReadSideImpl
//设置package包名称以及导入依赖的类
package com.lightbend.lagom.internal.scaladsl.persistence.cassandra
import akka.Done
import akka.actor.ActorSystem
import com.datastax.driver.core.BoundStatement
import com.lightbend.lagom.internal.persistence.cassandra.CassandraOffsetStore
import com.lightbend.lagom.scaladsl.persistence.ReadSideProcessor.ReadSideHandler
import com.lightbend.lagom.scaladsl.persistence.cassandra.CassandraReadSide.ReadSideHandlerBuilder
import com.lightbend.lagom.scaladsl.persistence.cassandra.{ CassandraReadSide, CassandraSession }
import com.lightbend.lagom.scaladsl.persistence.{ AggregateEvent, AggregateEventTag, EventStreamElement }
import scala.collection.immutable
import scala.concurrent.Future
import scala.reflect.ClassTag
private[lagom] final class CassandraReadSideImpl(
system: ActorSystem, session: CassandraSession, offsetStore: CassandraOffsetStore
) extends CassandraReadSide {
private val dispatcher = system.settings.config.getString("lagom.persistence.read-side.use-dispatcher")
implicit val ec = system.dispatchers.lookup(dispatcher)
override def builder[Event <: AggregateEvent[Event]](eventProcessorId: String): ReadSideHandlerBuilder[Event] = {
new ReadSideHandlerBuilder[Event] {
import CassandraAutoReadSideHandler.Handler
private var prepareCallback: AggregateEventTag[Event] => Future[Done] = tag => Future.successful(Done)
private var globalPrepareCallback: () => Future[Done] = () => Future.successful(Done)
private var handlers = Map.empty[Class[_ <: Event], Handler[Event]]
override def setGlobalPrepare(callback: () => Future[Done]): ReadSideHandlerBuilder[Event] = {
globalPrepareCallback = callback
this
}
override def setPrepare(callback: (AggregateEventTag[Event]) => Future[Done]): ReadSideHandlerBuilder[Event] = {
prepareCallback = callback
this
}
override def setEventHandler[E <: Event: ClassTag](handler: EventStreamElement[E] => Future[immutable.Seq[BoundStatement]]): ReadSideHandlerBuilder[Event] = {
val eventClass = implicitly[ClassTag[E]].runtimeClass.asInstanceOf[Class[Event]]
handlers += (eventClass -> handler.asInstanceOf[Handler[Event]])
this
}
override def build(): ReadSideHandler[Event] = {
new CassandraAutoReadSideHandler[Event](session, offsetStore, handlers, globalPrepareCallback, prepareCallback, eventProcessorId, dispatcher)
}
}
}
}
开发者ID:lagom,项目名称:lagom,代码行数:53,代码来源:CassandraReadSideImpl.scala
示例13: JournalEntity
//设置package包名称以及导入依赖的类
package io.namelos.journal.impl
import akka.Done
import com.lightbend.lagom.scaladsl.persistence.PersistentEntity.ReplyType
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, AggregateEventTag, PersistentEntity}
import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}
import play.api.libs.json.Json
import scala.collection.immutable.Seq
class JournalEntity extends PersistentEntity {
type Command = JournalCommand[_]
type Event = JournalEvent
type State = JournalState
def initialState = JournalState(0)
def behavior = {
case JournalState(_) => Actions()
.onCommand[Add, Done] { case (Add(x), ctx, _) => ctx.thenPersist(Added(x)) { _ => ctx.reply(Done) } }
.onReadOnlyCommand[GetState.type, Int] { case (GetState, ctx, JournalState(n)) => ctx.reply(n) }
.onEvent { case (Added(x), JournalState(n)) => JournalState(n + x) }
}
}
case class JournalState(n: Int)
object JournalState { implicit val format = Json.format[JournalState] }
sealed trait JournalEvent extends AggregateEvent[JournalEvent] { def aggregateTag = JournalEvent.Tag }
object JournalEvent { val Tag = AggregateEventTag[JournalEvent] }
case class Added(n: Int) extends JournalEvent
object Added { implicit val format = Json.format[Added] }
sealed trait JournalCommand[R] extends ReplyType[R]
case class Add(n: Int) extends JournalCommand[Done]
object Add { implicit val format = Json.format[Add] }
case object GetState extends JournalCommand[Int] { implicit val format = JsonSerializer.emptySingletonFormat(GetState) }
object JournalSerializerRegistry extends JsonSerializerRegistry {
override def serializers: Seq[JsonSerializer[_]] = Seq(
JsonSerializer[Add],
JsonSerializer[Added],
JsonSerializer[JournalState],
JsonSerializer[GetState.type]
)
}
开发者ID:namelos,项目名称:namelos-journal,代码行数:47,代码来源:JournalEntity.scala
示例14: aggregateTag
//设置package包名称以及导入依赖的类
package com.livelygig.product.message.impl
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, AggregateEventTag, AggregateEventTagger}
import com.lightbend.lagom.scaladsl.playjson.Jsonable
import com.livelygig.product.message.api.Message
import play.api.libs.json.Json
sealed trait MessageEvent extends AggregateEvent[MessageEvent] with Jsonable {
override def aggregateTag: AggregateEventTagger[MessageEvent] = MessageEvent.Tag
}
object MessageEvent {
val NumShards = 4
val Tag = AggregateEventTag.sharded[MessageEvent](NumShards)
}
case class MessagePosted(message: Message) extends MessageEvent
object MessagePosted {
implicit val format = Json.format[MessagePosted]
}
开发者ID:francescopersico,项目名称:i,代码行数:23,代码来源:MessageEvents.scala
示例15: aggregateTag
//设置package包名称以及导入依赖的类
package com.livelygig.product.user.impl
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, AggregateEventTag, AggregateEventTagger}
import com.lightbend.lagom.scaladsl.playjson.Jsonable
import com.livelygig.product.user.api.User
import play.api.libs.json.{Format, Json}
sealed trait UserEvent extends AggregateEvent[UserEvent] with Jsonable {
override def aggregateTag: AggregateEventTagger[UserEvent] = UserEvent.Tag
}
object UserEvent {
val NumShards = 4
val Tag = AggregateEventTag.sharded[UserEvent](NumShards)
}
case class UserCreated(user: User) extends UserEvent
object UserCreated {
implicit val format: Format[UserCreated] = Json.format
}
开发者ID:francescopersico,项目名称:i,代码行数:23,代码来源:UserEvents.scala
示例16: VehicleEvents
//设置package包名称以及导入依赖的类
package optrak.lagomtest.vehicles.impl
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, AggregateEventTag}
import optrak.lagomtest.data.Data.{TenantId, VehicleId}
import play.api.libs.json.{Format, Json}
object VehicleEvents {
// nb the vehicleevent needs to be aggregateEvent because it is used by read processor and needs an aggregate tag
sealed trait VehicleEvent extends AggregateEvent[VehicleEvent] {
override def aggregateTag = VehicleEvent.Tag
def tenantId: TenantId
def vehicleId: VehicleId
}
object VehicleEvent {
val NumShards = 4
val Tag = AggregateEventTag.sharded[VehicleEvent](NumShards)
}
case class VehicleCreated(tenantId: TenantId, vehicleId: VehicleId, capacity: Int) extends VehicleEvent
case class VehicleCapacityUpdated(tenantId: TenantId, vehicleId: VehicleId, newCapacity: Int) extends VehicleEvent
object VehicleCreated {
implicit def format: Format[VehicleCreated] = Json.format[VehicleCreated]
}
object VehicleCapacityUpdated {
implicit def format: Format[VehicleCapacityUpdated] = Json.format[VehicleCapacityUpdated]
}
}
开发者ID:TimPigden,项目名称:lagom-multitenant,代码行数:34,代码来源:VehicleEvents.scala
示例17: SiteEvents
//设置package包名称以及导入依赖的类
package optrak.lagomtest.sites.impl
import akka.Done
import com.lightbend.lagom.scaladsl.persistence.PersistentEntity.ReplyType
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, AggregateEventTag}
import optrak.lagomtest.data.Data.{PlanId, SiteId, TenantId}
import play.api.libs.json.{Format, Json}
object SiteEvents {
// nb the siteevent needs to be aggregateEvent because it is used by read processor and needs an aggregate tag
sealed trait SiteEvent extends AggregateEvent[SiteEvent] {
override def aggregateTag = SiteEvent.Tag
def tenantId: TenantId
def siteId: SiteId
}
object SiteEvent {
val NumShards = 4
val Tag = AggregateEventTag.sharded[SiteEvent](NumShards)
}
case class SiteCreated(tenantId: TenantId, siteId: SiteId, postcode: String) extends SiteEvent
case class SitePostcodeUpdated(tenantId: TenantId, siteId: SiteId, newPostcode: String) extends SiteEvent
object SiteCreated {
implicit def format: Format[SiteCreated] = Json.format[SiteCreated]
}
object SitePostcodeUpdated {
implicit def format: Format[SitePostcodeUpdated] = Json.format[SitePostcodeUpdated]
}
}
开发者ID:TimPigden,项目名称:lagom-multitenant,代码行数:36,代码来源:SiteEvents.scala
示例18: OrderEvents
//设置package包名称以及导入依赖的类
package optrak.lagomtest.orders.impl
import akka.Done
import com.lightbend.lagom.scaladsl.persistence.PersistentEntity.ReplyType
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, AggregateEventTag}
import optrak.lagomtest.data.Data._
import play.api.libs.json.{Format, Json}
object OrderEvents {
// nb the orderevent needs to be aggregateEvent because it is used by read processor and needs an aggregate tag
sealed trait OrderEvent extends AggregateEvent[OrderEvent] {
override def aggregateTag = OrderEvent.Tag
def tenantId: TenantId
def orderId: OrderId
}
object OrderEvent {
val NumShards = 4
val Tag = AggregateEventTag.sharded[OrderEvent](NumShards)
}
case class OrderCreated(tenantId: TenantId,
orderId: OrderId,
siteId: SiteId,
productId: ProductId,
quantity: Int) extends OrderEvent
case class OrderQuantityUpdated(tenantId: TenantId, orderId: OrderId, newQuantity: Int) extends OrderEvent
object OrderCreated {
implicit def format: Format[OrderCreated] = Json.format[OrderCreated]
}
object OrderQuantityUpdated {
implicit def format: Format[OrderQuantityUpdated] = Json.format[OrderQuantityUpdated]
}
}
开发者ID:TimPigden,项目名称:lagom-multitenant,代码行数:40,代码来源:OrderEvents.scala
示例19: ProductEvents
//设置package包名称以及导入依赖的类
package optrak.lagomtest.products.impl
import akka.Done
import com.lightbend.lagom.scaladsl.persistence.PersistentEntity.ReplyType
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, AggregateEventTag}
import optrak.lagomtest.data.Data.{PlanId, ProductId, TenantId}
import play.api.libs.json.{Format, Json}
object ProductEvents {
// nb the productevent needs to be aggregateEvent because it is used by read processor and needs an aggregate tag
sealed trait ProductEvent extends AggregateEvent[ProductEvent] {
override def aggregateTag = ProductEvent.Tag
def tenantId: TenantId
def productId: ProductId
}
object ProductEvent {
val NumShards = 4
val Tag = AggregateEventTag.sharded[ProductEvent](NumShards)
}
case class ProductCreated(tenantId: TenantId, productId: ProductId, size: Int, group: String) extends ProductEvent
case class ProductSizeUpdated(tenantId: TenantId, productId: ProductId, newSize: Int) extends ProductEvent
case class ProductGroupUpdated(tenantId: TenantId, productId: ProductId, newGroup: String) extends ProductEvent
case class ProductCancelled(tenantId: TenantId, productId: ProductId) extends ProductEvent
object ProductCreated {
implicit def format: Format[ProductCreated] = Json.format[ProductCreated]
}
object ProductSizeUpdated {
implicit def format: Format[ProductSizeUpdated] = Json.format[ProductSizeUpdated]
}
object ProductGroupUpdated {
implicit def format: Format[ProductGroupUpdated] = Json.format[ProductGroupUpdated]
}
object ProductCancelled {
implicit def format: Format[ProductCancelled] = Json.format[ProductCancelled]
}
}
开发者ID:TimPigden,项目名称:lagom-multitenant,代码行数:44,代码来源:ProductEvents.scala
示例20: TenantEvents
//设置package包名称以及导入依赖的类
package optrak.lagomtest.tenant.impl
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, AggregateEventTag}
import optrak.lagomtest.data.Data.PlanId
import play.api.libs.json.{Format, Json}
object TenantEvents {
// nb the tenant event needs to be aggregateEvent because it is used by read processor and needs an aggregate tag
sealed trait TenantEvent extends AggregateEvent[TenantEvent] {
override def aggregateTag = TenantEvent.Tag
}
object TenantEvent {
val NumShards = 4
val Tag = AggregateEventTag.sharded[TenantEvent](NumShards)
}
case class TenantCreated(id: String, description: String) extends TenantEvent
object TenantCreated {
implicit val format: Format[TenantCreated] = Json.format[TenantCreated]
}
case class ModelCreated(id: PlanId, description: String) extends TenantEvent
object ModelCreated {
implicit val format: Format[ModelCreated] = Json.format[ModelCreated]
}
case class ModelRemoved(id: PlanId) extends TenantEvent
object ModelRemoved {
implicit val format: Format[ModelRemoved] = Json.format[ModelRemoved]
}
}
开发者ID:TimPigden,项目名称:lagom-multitenant,代码行数:37,代码来源:TenantEvents.scala
注:本文中的com.lightbend.lagom.scaladsl.persistence.AggregateEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论