An Akka DDD from scratch

最近的多人游戏开发上,对Akka 的使用非常感兴趣。在我的工作上,我和 @DsFishlabs 使用了 Spring Boot 以及 Spring Cloud 作为我们的内部服务。

在本文,我想尝试基于 Akka 来构建相似的系统,功能方面跟原来差不多,但这里我想尝试一个不同的方式。其中包含有 Scala,Akka Cluster ShardingAkka Persistence aka.Event Sourcing 以及 DDD

所有代码会在Github上,可能需要看看 extractShardId 方面的资料。

Read more

Domain Design Relish

More formally, a domain model is a blueprint of the relationships between the various entities of the problem domain and sketches out other important details, such as the following:

  • Objects that belong to the domain
  • Behaviors that those objects demonstrate in interacting among themselves
  • The language that the domain speaks
  • The context within which the model operates
Read more

CAP理论

分布式网络环境中,时间和顺序是无法预估的,要保证得到的数据正确,我们需要一些折衷的选择。

2000年7月19号,Eric Brewer在ACM研讨会上关于分布式计算的原则(Principlesof Distributed Computing,PODC)所做的开题演讲中,提出了一个猜想(后来的成为著名的Brewer猜想):

applications become more web-based we should stop worrying about data consistency, because if we want high availability in these new distributed applications, then guaranteed consistency of data is something we cannot have, thus giving anyone with three servers and a keen eye for customer experience permission to start an internet scale business.

2年后,2002年,麻省理工(MIT)的Seth Gilbert和NancyLynch,理论上证明了Brewer猜想是正确的,就此Brewer定理(Theorem)诞生了。

Read more

Monoids and Monads

Haskell由于使用了Monad这种较费解的概念来控制副作用而遭到了一些批评意见。Wadler试图平息这些质疑,他解释说:“一个单子(Monad)说白了不过就是自函子范畴上的一个幺半群而已,这有什么难以理解的?”
A monad is just a monoid in the category of endofunctors, what’s the problem?

这一句话包含了好几个概念:单子(monad),自函子(Endo-Functor),幺半群(Monoid),范畴(category)。

Read more