io.vlingo.lattice.model.process.Process Maven / Gradle / Ivy
Show all versions of vlingo-lattice Show documentation
// Copyright © 2012-2020 VLINGO LABS. All rights reserved.
//
// This Source Code Form is subject to the terms of the
// Mozilla Public License, v. 2.0. If a copy of the MPL
// was not distributed with this file, You can obtain
// one at https://mozilla.org/MPL/2.0/.
package io.vlingo.lattice.model.process;
import java.util.List;
import java.util.function.Supplier;
import io.vlingo.common.Completes;
import io.vlingo.lattice.model.Command;
import io.vlingo.lattice.model.DomainEvent;
import io.vlingo.symbio.Source;
/**
* Definition for a long-running process.
* @param my state type
*/
public interface Process {
/**
* Answer my state as a {@code Chronicle}.
* @return {@code Chronicle}
*/
Chronicle chronicle();
/**
* Answer my id, which is used for correlation among my collaborators.
* @return String
*/
String id();
/**
* Cause the {@code command} to be processed by persisting it as a {@code ProcessMessage}.
*
* Uses the underlying persistence mechanism to
* ensure the {@code command} is permanent, enabling
* a backing {@code Exchange} message to be enqueued
* with guaranteed delivery semantics.
* @param command the Command to apply
*/
void process(final Command command);
/**
* Answer {@code Completes}, while causing the {@code command} to be processed by persisting
* it as a {@code ProcessMessage}, followed by the execution of a possible {@code andThen}.
*
* Uses the underlying persistence mechanism to
* ensure the {@code command} is permanent, enabling
* a backing {@code Exchange} message to be enqueued
* with guaranteed delivery semantics.
* @param command the Command to apply
* @param andThen the {@code Supplier} executed following the application of command
* @param the return type of the andThen {@code Supplier}
* @return {@code Completes}
*/
Completes process(final Command command, final Supplier andThen);
/**
* Cause the {@code event} to be processed by persisting it as a {@code ProcessMessage}.
*
* Uses the underlying persistence mechanism to
* ensure the {@code event} is permanent, enabling
* a backing {@code Exchange} message to be enqueued
* with guaranteed delivery semantics.
* @param event the DomainEvent to apply
*/
void process(final DomainEvent event);
/**
* Answer {@code Completes}, while causing the {@code event} to be processed by persisting
* it as a {@code ProcessMessage}, followed by the execution of a possible {@code andThen}.
*
* Uses the underlying persistence mechanism to
* ensure the {@code event} is permanent, enabling
* a backing {@code Exchange} message to be enqueued
* with guaranteed delivery semantics.
* @param event the DomainEvent to apply
* @param andThen the {@code Supplier} executed following the application of event
* @param the return type of the andThen {@code Supplier}
* @return {@code Completes}
*/
Completes process(final DomainEvent event, final Supplier andThen);
/**
* Cause the {@code sources} to be processed by persisting each as a {@code ProcessMessage}.
*
* Uses the underlying persistence mechanism to
* ensure the {@code sources} are permanent, enabling
* a backing {@code Exchange} message to be enqueued
* with guaranteed delivery semantics.
* @param sources the {@code List