persistence module doc. update
This commit is contained in:
@@ -6,6 +6,11 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Contract definition for Aggregate wrapper
|
||||
* @param <A> - Aggregate type
|
||||
* @param <C> - Command type
|
||||
*/
|
||||
public interface AggregateActor<A, C extends Command> {
|
||||
|
||||
<S> Mono<S> getState(Function<A, S> stateFactory);
|
||||
|
||||
@@ -4,6 +4,12 @@ import com.mz.reactor.ddd.common.api.command.Command;
|
||||
import com.mz.reactor.ddd.common.api.event.DomainEvent;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* Aggregate facade contract for operations related with aggregate.
|
||||
* @param <A> - Aggregate type
|
||||
* @param <C> - Command type
|
||||
* @param <S> - State type, representing a state of aggregate
|
||||
*/
|
||||
public interface AggregateFacade<A, C extends Command,S> {
|
||||
|
||||
Mono<S> execute(C command, String aggregateID);
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
package com.mz.reactor.ddd.reactorddd.persistance.aggregate;
|
||||
|
||||
public interface AggregateFactory {
|
||||
}
|
||||
@@ -5,6 +5,12 @@ import com.mz.reactor.ddd.common.api.command.CommandResult;
|
||||
import com.mz.reactor.ddd.common.api.valueobject.Id;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* {@link AggregateRepository} contract definition.
|
||||
* @param <A> - Aggregate type
|
||||
* @param <C> - Command type
|
||||
* @param <S> - State type, representing a state of aggregate
|
||||
*/
|
||||
public interface AggregateRepository<A, C extends Command,S> {
|
||||
|
||||
Mono<CommandResult> execute(C cmd, Id aggregateId);
|
||||
|
||||
@@ -78,7 +78,9 @@ public class AggregateRepositoryImpl<A, C extends Command, S> implements Aggrega
|
||||
eventHandler,
|
||||
aggregateFactory,
|
||||
Optional.ofNullable(eventSource.get().get(id)).orElseGet(List::of),
|
||||
this::persistAll));
|
||||
this::persistAll
|
||||
)
|
||||
);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -100,7 +102,8 @@ public class AggregateRepositoryImpl<A, C extends Command, S> implements Aggrega
|
||||
return Mono.just(id)
|
||||
.flatMap(i -> Optional.ofNullable(cache.getIfPresent(i))
|
||||
.map(a -> a.getState(this.stateFactory))
|
||||
.orElseGet(Mono::empty));
|
||||
.orElseGet(Mono::empty)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user