You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>The basic API use vavr for several reasons : * <code>Either</code> : to handle success or error * <code>Option</code> : instead of java Optional to handle missing values * <code>Tuple</code> : to collect data * <code>Tuple0</code> : to return values not handled (like Void but not exactly the same) * <code>List</code> : instead of java List, because the API is better * <code>Lazy</code> : for lazy values </p>
156
-
<p>The basic API, is exposed with package <code>fr.maif.eventsourcing</code>. </p>
<p>If you don’t want to use vavr, there is a vanilla API : * <code>Either</code> -> <code>fr.maif.eventsourcing.Result</code>: a custom type to handle success or error * <code>Option</code> -> <code>Optional</code> * <code>Tuple</code> : internal * <code>Tuple0</code> -> <code>fr.maif.eventsourcing.Unit</code> : a custom type to return values not handled (like Void but not exactly the same) * <code>List</code> : -> <code>java.util.List</code><br/>* <code>Lazy</code> : for lazy values</p>
159
-
<p>The package to use is <code>fr.maif.eventsourcing.vanilla</code> : * <code>AggregateStore</code> * <code>CommandHandler</code> * <code>EventHandler</code> * <code>EventProcessor</code> * <code>EventPublisher</code> * <code>Events</code> * <code>EventStore</code> * <code>ProcessingSuccess</code> * <code>Projection</code> * <code>SimpleCommand</code></p>
<p>If you don’t to handle the non-blocking aspect, you can implement blocking interface, ie the blocking <code>CommandHandler</code>. </p>
162
-
<p>The component to use * <code>fr.maif.eventsourcing.blocking.CommandHandler</code> : with standard API (vavr) * <code>fr.maif.eventsourcing.vanilla.blocking.CommandHandler</code> : with vanilla API</p>
163
-
<h2><ahref="#reactive-api-using-reactor" name="reactive-api-using-reactor" class="anchor"><spanclass="anchor-link"></span></a>Reactive API using reactor</h2>
164
-
<p>There is a reactor API to use <code>Mono</code> instead of <code>CompletionStage</code>. The classes are prefixed with <code>Reactor</code> : * <code>ReactorAggregateStore</code> * <code>ReactorCommandHandler</code> * <code>ReactorEventProcessor</code> * <code>ReactorEventStore</code> * <code>ReactorPostgresKafkaEventProcessorBuilder</code> * <code>ReactorProjection</code> * <code>ReactorTransactionManager</code></p>
165
-
<p>At the moment, the reactor API use vavr, there is no vanilla API. </p>
153
+
<p>Thoth is non-blocking by default and rely on vavr but, you can choose if you use it or not.</p>
154
+
<h2><ahref="#fifty-shades-of-apis" name="fifty-shades-of-apis" class="anchor"><spanclass="anchor-link"></span></a>Fifty shades of APIs</h2>
<li><code>Tuple0</code> -> <code>fr.maif.eventsourcing.Unit</code> : a custom type to return values not handled (like Void but not exactly the same)</li>
public Result<String, Events<BankEvent, List<String>>> handleCommand(
235
+
TxCtx transactionContext,
236
+
Optional<Account> previousState,
237
+
BankCommand command) {
238
+
return switch (command) {
239
+
case Withdraw withdraw -> this.handleWithdraw(previousState, withdraw);
240
+
case Deposit deposit -> this.handleDeposit(previousState, deposit);
241
+
case OpenAccount openAccount -> this.handleOpening(openAccount);
242
+
case CloseAccount close -> this.handleClosing(previousState, close);
243
+
};
244
+
}
245
+
}
246
+
</code></pre>
247
+
<h3><ahref="#reactive-api-using-reactor" name="reactive-api-using-reactor" class="anchor"><spanclass="anchor-link"></span></a>Reactive API using reactor</h3>
248
+
<p>There is a reactor API to use <code>Mono</code> instead of <code>CompletionStage</code>. The classes are prefixed with <code>Reactor</code> :</p>
<h3><ahref="#concepts-and-vocabulary" name="concepts-and-vocabulary" class="anchor"><spanclass="anchor-link"></span></a>Concepts and vocabulary</h3>
278
+
<ul>
279
+
<li>a command : an action coming from the user that the system has to handle</li>
280
+
<li>an event : something that append in the system</li>
281
+
<li>a journal : a place where the events are stored</li>
282
+
<li>a state or aggregate : the current state, the results of the previous events</li>
283
+
<li>a projection : an alternative view of the events, this is a read model</li>
284
+
</ul>
285
+
<h3><ahref="#overview-of-interface-to-implement" name="overview-of-interface-to-implement" class="anchor"><spanclass="anchor-link"></span></a>Overview of interface to implement</h3>
286
+
<p>Here the list of interface you need or, you could implement (and the reason why).</p>
287
+
<table>
288
+
<thead>
289
+
<tr>
290
+
<th>Interface </th>
291
+
<th>Required </th>
292
+
<th>Role </th>
293
+
</tr>
294
+
</thead>
295
+
<tbody>
296
+
<tr>
297
+
<td><code>State</code></td>
298
+
<td>yes </td>
299
+
<td>The current state built from events </td>
300
+
</tr>
301
+
<tr>
302
+
<td><code>Command</code></td>
303
+
<td>yes </td>
304
+
<td>The command represents the data that comes in </td>
305
+
</tr>
306
+
<tr>
307
+
<td><code>CommandHandler</code></td>
308
+
<td>yes </td>
309
+
<td>The component that handle commands and produce events </td>
310
+
</tr>
311
+
<tr>
312
+
<td><code>EventHandler</code></td>
313
+
<td>yes </td>
314
+
<td>The component that handle events and produce a state </td>
315
+
</tr>
316
+
<tr>
317
+
<td><code>Projection</code></td>
318
+
<td>if you need read models </td>
319
+
<td>The component that handle events and produce read model </td>
0 commit comments