简体   繁体   English

我的Lagom服务的体系结构?

[英]Architecture of my Lagom Service?

I am creating a service using Lagom framework and need some help in the architecture of the application. 我正在使用Lagom框架创建服务,并且需要一些有关应用程序体系结构的帮助。 There is Employee service which contains information about all the employees. 有员工服务,其中包含有关所有员工的信息。 Each employee has an address. 每个员工都有一个地址。 The models are like these, 这些模型是这样的,

class Employee {
      String firstName;
      String lastName;
      String email;
      Address address;
}

class Address {
    String apt;
    String street;
    String city;
    String state;
    String pin;
}

Right now I am creating a single service for employee and thinking of using Cassandra for the database. 现在,我正在为员工创建一项服务,并考虑将Cassandra用于数据库。 Should I create a single table for employee which contains a custom user type (UDT) of address or create a separate service for address and use this service in the employee service. 我应该为员工创建一个包含表的自定义用户类型(UDT)地址的表还是为地址创建单独的服务并在员工服务中使用此服务。 Also can someone point me to a Lagom framework example which demonstrates the use of UDT in Cassandra. 也有人可以给我指出一个Lagom框架示例,该示例演示在Cassandra中使用UDT。

The recommended way of persisting data in Lagom is to use event sourcing, described here: 在Lagom中持久存储数据的推荐方法是使用事件源,如下所述:

https://www.lagomframework.com/documentation/1.3.x/java/PersistentEntity.html https://www.lagomframework.com/documentation/1.3.x/java/PersistentEntity.html

So you don't store your state directly in tables, you store the events that led to that state. 因此,您不会将状态直接存储在表中,而是存储导致该状态的事件。 For example, you might have an EmployeeAdded event, and an EmployeeAddressChanged event, and so on, depending on what make sense to model in your business use case. 例如,您可能有一个EmployeeAdded事件和一个EmployeeAddressChanged事件,依此类推,具体取决于在业务用例中进行建模的意义。 These are the things that get persisted, and then when the employee is loaded, Lagom will replay all the persisted events to create the Employee type that you have above. 这些都是持久化的东西,然后在加载员工时,Lagom将重播所有持久化事件以创建您上面具有的Employee类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM