mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 08:58:26 +00:00
fix: correct typos in event-sourcing (#2442)
This commit is contained in:
@@ -16,7 +16,7 @@ Instead of storing just the current state of the data in a domain, use an append
|
||||
## Applicability
|
||||
Use the Event Sourcing pattern when
|
||||
|
||||
* You need very high performance on persisting your application state even your application state have a complex relational data structure
|
||||
* You need very high performance on persisting your application state even your application state has a complex relational data structure
|
||||
* You need log of changes of your application state and ability to restore a state of any moment in time.
|
||||
* You need to debug production problems by replaying the past events.
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.util.Date;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Event Sourcing : Instead of storing just the current state of the data in a domain, use an
|
||||
* Event Sourcing: Instead of storing just the current state of the data in a domain, use an
|
||||
* append-only store to record the full series of actions taken on that data. The store acts as the
|
||||
* system of record and can be used to materialize the domain objects. This can simplify tasks in
|
||||
* complex domains, by avoiding the need to synchronize the data model and the business domain,
|
||||
@@ -42,11 +42,11 @@ import lombok.extern.slf4j.Slf4j;
|
||||
* transactional data, and maintain full audit trails and history that can enable compensating
|
||||
* actions.
|
||||
*
|
||||
* <p>This App class is an example usage of Event Sourcing pattern. As an example, two bank account
|
||||
* is created, then some money deposit and transfer actions are taken so a new state of accounts is
|
||||
* created. At that point, state is cleared in order to represent a system shot down. After the shot
|
||||
* down, system state is recovered by re-creating the past events from event journal. Then state is
|
||||
* printed so a user can view the last state is same with the state before system shot down.
|
||||
* <p>This App class is an example usage of an Event Sourcing pattern. As an example, two bank accounts
|
||||
* are created, then some money deposit and transfer actions are taken, so a new state of accounts is
|
||||
* created. At that point, state is cleared in order to represent a system shut-down. After the shut-down,
|
||||
* system state is recovered by re-creating the past events from event journals. Then state is
|
||||
* printed so a user can view the last state is same with the state before a system shut-down.
|
||||
*
|
||||
* <p>Created by Serdar Hamzaogullari on 06.08.2017.
|
||||
*/
|
||||
|
||||
@@ -115,7 +115,7 @@ public class Account {
|
||||
/**
|
||||
* Handles the AccountCreateEvent.
|
||||
*
|
||||
* @param accountCreateEvent the account create event
|
||||
* @param accountCreateEvent the account created event
|
||||
*/
|
||||
public void handleEvent(AccountCreateEvent accountCreateEvent) {
|
||||
AccountAggregate.putAccount(this);
|
||||
|
||||
+4
-3
@@ -29,8 +29,9 @@ import com.iluwatar.event.sourcing.state.AccountAggregate;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* This is the class that implements account create event. Holds the necessary info for an account
|
||||
* create event. Implements the process function that finds the event related domain objects and
|
||||
* This is the class that implements account created event.
|
||||
* Holds the necessary info for an account created event.
|
||||
* Implements the process function that finds the event-related domain objects and
|
||||
* calls the related domain object's handle event functions
|
||||
*
|
||||
* <p>Created by Serdar Hamzaogullari on 06.08.2017.
|
||||
@@ -42,7 +43,7 @@ public class AccountCreateEvent extends DomainEvent {
|
||||
private final String owner;
|
||||
|
||||
/**
|
||||
* Instantiates a new Account create event.
|
||||
* Instantiates a new Account created event.
|
||||
*
|
||||
* @param sequenceId the sequence id
|
||||
* @param createdTime the created time
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ import lombok.Getter;
|
||||
|
||||
/**
|
||||
* This is the class that implements money deposit event. Holds the necessary info for a money
|
||||
* deposit event. Implements the process function that finds the event related domain objects and
|
||||
* deposit event. Implements the process function that finds the event-related domain objects and
|
||||
* calls the related domain object's handle event functions
|
||||
*
|
||||
* <p>Created by Serdar Hamzaogullari on 06.08.2017.
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ import lombok.Getter;
|
||||
|
||||
/**
|
||||
* This is the class that implements money transfer event. Holds the necessary info for a money
|
||||
* transfer event. Implements the process function that finds the event related domain objects and
|
||||
* transfer event. Implements the process function that finds the event-related domain objects and
|
||||
* calls the related domain object's handle event functions
|
||||
*
|
||||
* <p>Created by Serdar Hamzaogullari on 06.08.2017.
|
||||
|
||||
+2
-2
@@ -91,7 +91,7 @@ public class JsonFileJournal {
|
||||
} else if (domainEvent instanceof MoneyTransferEvent) {
|
||||
jsonElement = gson.toJsonTree(domainEvent, MoneyTransferEvent.class);
|
||||
} else {
|
||||
throw new RuntimeException("Journal Event not recegnized");
|
||||
throw new RuntimeException("Journal Event not recognized");
|
||||
}
|
||||
|
||||
try (var output = new BufferedWriter(
|
||||
@@ -113,7 +113,7 @@ public class JsonFileJournal {
|
||||
|
||||
|
||||
/**
|
||||
* Read next domain event.
|
||||
* Read the next domain event.
|
||||
*
|
||||
* @return the domain event
|
||||
*/
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Intergartion Test for Event Sourcing state recovery
|
||||
* Integration Test for Event-Sourcing state recovery
|
||||
* <p>
|
||||
* Created by Serdar Hamzaogullari on 19.08.2017.
|
||||
*/
|
||||
@@ -95,4 +95,4 @@ class IntegrationTest {
|
||||
assertEquals(accountOfJonBeforeShotDown.getMoney(), accountOfJonAfterShotDown.getMoney());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user