在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:akka-data-replication开源软件地址:https://gitee.com/mefaso/akka-data-replication开源软件介绍:本项目已经成为akka实验项目 将在akka2.4支持 Akka Data ReplicationThis is an EARLY PREVIEW of a library for replication of data in an Akka cluster.It is a replicated in-memory data store supporting low latency and high availabilityrequirements. The data must be so called Conflict Free Replicated Data Types (CRDTs),i.e. they provide a monotonic merge function and the state changes always converge. For good introduction to CRDTs you should watch theEventually Consistent Data Structurestalk by Sean Cribbs. CRDTs can't be used for all types of problems, but when they can they have very nice properties:
Built in data types:
You can use your own custom data types by implementing the The A short example of how to use it: class DataBot extends Actor with ActorLogging { import DataBot._ import Replicator._ val replicator = DataReplication(context.system).replicator implicit val cluster = Cluster(context.system) import context.dispatcher val tickTask = context.system.scheduler.schedule(5.seconds, 5.seconds, self, Tick) replicator ! Subscribe("key", self) def receive = { case Tick => val s = ThreadLocalRandom.current().nextInt(97, 123).toChar.toString if (ThreadLocalRandom.current().nextBoolean()) { // add log.info("Adding: {}", s) replicator ! Update("key", ORSet(), WriteLocal)(_ + s) } else { // remove log.info("Removing: {}", s) replicator ! Update("key", ORSet(), WriteLocal)(_ - s) } case _: UpdateResponse => // ignore case Changed("key", data: ORSet) => log.info("Current elements: {}", data.value) } override def postStop(): Unit = tickTask.cancel()} The full source code for this sample is inDataBot.scala. More detailed documentation can be found in theScalaDocof Two other examples: DependencyLatest version of Add the following lines to your resolvers += "patriknw at bintray" at "http://dl.bintray.com/patriknw/maven"libraryDependencies += "com.github.patriknw" %% "akka-data-replication" % "0.8" More Resources
|
请发表评论