• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala AggregateEventTag类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中com.lightbend.lagom.scaladsl.persistence.AggregateEventTag的典型用法代码示例。如果您正苦于以下问题:Scala AggregateEventTag类的具体用法?Scala AggregateEventTag怎么用?Scala AggregateEventTag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了AggregateEventTag类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: MessageEventProcessor

//设置package包名称以及导入依赖的类
package sample.helloworldconsumer.impl

import akka.Done
import com.datastax.driver.core.{BoundStatement, PreparedStatement}
import com.lightbend.lagom.scaladsl.persistence.ReadSideProcessor.ReadSideHandler
import com.lightbend.lagom.scaladsl.persistence.cassandra.{CassandraReadSide, CassandraSession}
import com.lightbend.lagom.scaladsl.persistence.{AggregateEventTag, EventStreamElement, ReadSideProcessor}

import scala.concurrent.{ExecutionContext, Future}


class MessageEventProcessor(cassandraReadSide: CassandraReadSide, cassandraSession: CassandraSession)
                           (implicit ec: ExecutionContext) extends ReadSideProcessor[MessageEvent] {

  private var insertWordStmt: PreparedStatement = _

  override def buildHandler(): ReadSideHandler[MessageEvent] = {
    cassandraReadSide.builder[MessageEvent]("message_offset")
      .setGlobalPrepare(createTable)
      .setPrepare { tags =>
        prepareStatements
      }
      .setEventHandler[MessageSaved](insertWord)
      .build()
  }

  override def aggregateTags: Set[AggregateEventTag[MessageEvent]] = Set(MessageEventTag.INSTANCE)

  private def createTable(): Future[Done] = {
    for {
      _ <- cassandraSession.executeCreateTable(
        """        CREATE TABLE IF NOT EXISTS wordcounttest (
                      words text,
                      insertion_time timestamp,
                      PRIMARY KEY (words,insertion_time)
                    )WITH CLUSTERING ORDER BY (insertion_time DESC)
        """)
    } yield Done
  }

  private def prepareStatements(): Future[Done] = {
    for {
      insert <- cassandraSession.prepare(
        """insert into wordcounttest(words ,insertion_time) values(? ,toTimestamp(now())) """)
    } yield {
      insertWordStmt = insert
      Done
    }
  }

  private def insertWord(started: EventStreamElement[MessageSaved]): Future[List[BoundStatement]] = {
    Future.successful {
     val words = started.event.msg.replaceAll("[^\\p{L}\\p{Nd}]+", " ").split(" ").toList
     words.map{ word=> insertWordStmt.bind(word) }
    }
  }

} 
开发者ID:knoldus,项目名称:lagom-scala-wordcount.g8,代码行数:59,代码来源:MessageEventProcessor.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 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


示例4: 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


示例5: 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


示例6: 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


示例7: IdentityEventProcessor

//设置package包名称以及导入依赖的类
package io.digitalcat.publictransportation.services.identity.impl

import java.util.UUID

import akka.Done
import com.datastax.driver.core.PreparedStatement
import com.lightbend.lagom.scaladsl.persistence.ReadSideProcessor.ReadSideHandler
import com.lightbend.lagom.scaladsl.persistence.cassandra.{CassandraReadSide, CassandraSession}
import com.lightbend.lagom.scaladsl.persistence.{AggregateEventTag, EventStreamElement, ReadSideProcessor}

import scala.concurrent.{ExecutionContext, Future}

class IdentityEventProcessor(session: CassandraSession, readSide: CassandraReadSide)(implicit ec: ExecutionContext) extends ReadSideProcessor[IdentityEvent] {
  private var insertUserStatement: PreparedStatement = _
  private var reportIdToReservedUsernamesStatement: PreparedStatement = _
  private var reportIdToReservedEmailsStatement: PreparedStatement = _

  override def buildHandler(): ReadSideHandler[IdentityEvent] = {
    readSide.builder[IdentityEvent]("identityEventOffset")
      .setPrepare { tag =>
        prepareStatements()
      }.setEventHandler[UserCreated](insertUser)
      .build()
  }

  override def aggregateTags: Set[AggregateEventTag[IdentityEvent]] = {
    IdentityEvent.Tag.allTags
  }

  private def prepareStatements(): Future[Done] = {
    for {
      insertUser <- session.prepare("INSERT INTO users(id, client_id, username, email, first_name, last_name, hashed_password) VALUES (?, ?, ?, ?, ?, ?, ?)")
      reportIdToReservedUsernames <- session.prepare("UPDATE reserved_usernames SET user_id = ? WHERE username = ?")
      reportIdToReservedEmails <- session.prepare("UPDATE reserved_emails SET user_id = ? WHERE email = ?")
    } yield {
      insertUserStatement = insertUser
      reportIdToReservedUsernamesStatement = reportIdToReservedUsernames
      reportIdToReservedEmailsStatement = reportIdToReservedEmails
      Done
    }
  }

  private def insertUser(user: EventStreamElement[UserCreated]) = {
    Future.successful(
      List(
        insertUserStatement.bind(
          user.event.userId,
          UUID.fromString(user.entityId),
          user.event.username,
          user.event.email,
          user.event.firstName,
          user.event.lastName,
          user.event.hashedPassword
        ),
        reportIdToReservedUsernamesStatement.bind(user.event.userId, user.event.username),
        reportIdToReservedEmailsStatement.bind(user.event.userId, user.event.email)
      )
    )
  }
} 
开发者ID:dpalinic,项目名称:lagom-jwt-authentication,代码行数:61,代码来源:IdentityEventProcessor.scala


示例8: BlogEventProcessor

//设置package包名称以及导入依赖的类
package docs.home.scaladsl.persistence

import com.lightbend.lagom.scaladsl.persistence.AggregateEventTag
import com.lightbend.lagom.scaladsl.persistence.ReadSideProcessor

trait BlogEventProcessorInitial {

  //#processor
  class BlogEventProcessor extends ReadSideProcessor[BlogEvent] {

    override def buildHandler(): ReadSideProcessor.ReadSideHandler[BlogEvent] = {
      // TODO build read side handler
      ???
    }

    override def aggregateTags: Set[AggregateEventTag[BlogEvent]] = {
      // TODO return the tag for the events
      ???
    }
  }
  //#processor
} 
开发者ID:lagom,项目名称:lagom,代码行数:23,代码来源:BlogEventProcessorInitial.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.AggregateEventTag类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala envOrElse类代码示例发布时间:2022-05-23
下一篇:
Scala SprayJsonSupport类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap