public interface Mole
This is the central place to interact with molr missions from the client side.
It provides methods to query what missions are available, instantiate and run/step through them. It depends on the implementation, if there is network communication behind or not. In general, the agency holds a state. However, all the returned streams shall cache the last values, so that whenever a new client subscribes, it gets an immediate update of the actual value.
Note that the full agency is designed in an asynchronous manner!
Modifier and Type | Method and Description |
---|---|
reactor.core.publisher.Mono<io.molr.commons.domain.MissionHandle> |
instantiate(io.molr.commons.domain.Mission mission,
java.util.Map<java.lang.String,java.lang.Object> params)
Instantiates the given mission with the given parameters (Currently only string and integer parameters are
supported).
|
void |
instruct(io.molr.commons.domain.MissionHandle handle,
io.molr.commons.domain.Strand strand,
io.molr.commons.domain.StrandCommand command)
Instructs the mission instance identified by the given handle to execute the given command on the given strand.
|
void |
instructRoot(io.molr.commons.domain.MissionHandle handle,
io.molr.commons.domain.StrandCommand command)
Instructs the root strand of the mission identified by the given handle to execute a given command.
|
reactor.core.publisher.Flux<io.molr.commons.domain.MissionOutput> |
outputsFor(io.molr.commons.domain.MissionHandle handle)
Retrieves a stream of the actual output of one mission instance.
|
reactor.core.publisher.Mono<io.molr.commons.domain.MissionParameterDescription> |
parameterDescriptionOf(io.molr.commons.domain.Mission mission)
Retrieves information on what parameters a mission expects (name, type, optional or mandatory).
|
reactor.core.publisher.Mono<io.molr.commons.domain.MissionRepresentation> |
representationOf(io.molr.commons.domain.Mission mission)
Retrieves the initial (!) representation of a mission, meaning when the mission is not instantiated/running.
|
reactor.core.publisher.Flux<io.molr.commons.domain.MissionRepresentation> |
representationsFor(io.molr.commons.domain.MissionHandle handle)
Delivers updates of the representation of the mission.
|
reactor.core.publisher.Flux<io.molr.commons.domain.AgencyState> |
states()
Retrieves a stream of the actual
AgencyState . |
reactor.core.publisher.Flux<io.molr.commons.domain.MissionState> |
statesFor(io.molr.commons.domain.MissionHandle handle)
Retrieves a stream emitting new items anytime the state of the mission instance changes.
|
reactor.core.publisher.Mono<io.molr.commons.domain.MissionHandle> instantiate(io.molr.commons.domain.Mission mission, java.util.Map<java.lang.String,java.lang.Object> params)
Strand
on its first (or only) Block
.
At this point in time, commands can be sent to the mission instance through the instruct(MissionHandle,
Strand, StrandCommand)
method (non-allowed commands shall be ignored by the agency and the underlying moles).
The allowed commands (and other information) can be queried through the statesFor(MissionHandle)
method.
mission
- the mission which shall be instantiatedparams
- a map from parameter name to parameter value to instantiate the missionreactor.core.publisher.Flux<io.molr.commons.domain.AgencyState> states()
AgencyState
. This state contains information about all the available
missions and those which are currently instantiated. The stream shall emit a new item whenever the state changes
and shall be long-living, so basically never complete during the lifetime of the agency.reactor.core.publisher.Flux<io.molr.commons.domain.MissionState> statesFor(io.molr.commons.domain.MissionHandle handle)
handle
- a handle representing the mission instance for which the states shall be retrievedreactor.core.publisher.Flux<io.molr.commons.domain.MissionOutput> outputsFor(io.molr.commons.domain.MissionHandle handle)
handle
- a handle representing the mission instance for which the output shall be queried.reactor.core.publisher.Flux<io.molr.commons.domain.MissionRepresentation> representationsFor(io.molr.commons.domain.MissionHandle handle)
handle
- the handle of the mission for which to retrieve representation updatesreactor.core.publisher.Mono<io.molr.commons.domain.MissionRepresentation> representationOf(io.molr.commons.domain.Mission mission)
representationsFor(MissionHandle)
, to be notified of any changes in the
representation.mission
- the mission for which to retrieve the initial (!) representationreactor.core.publisher.Mono<io.molr.commons.domain.MissionParameterDescription> parameterDescriptionOf(io.molr.commons.domain.Mission mission)
mission
- the mission for which the information shall be queried.void instruct(io.molr.commons.domain.MissionHandle handle, io.molr.commons.domain.Strand strand, io.molr.commons.domain.StrandCommand command)
statesFor(MissionHandle)
. However,
due to the asynchronous nature of the whole framework, it can never be guaranteed that the command is still
allowed when sent. For that reason, non-allowed commands shall be ignored by the implementations of an agency and
underlying moles.handle
- a handle representing the mission instance on which the command shall be executedstrand
- the strand of the mission instance on which the command shall be executedcommand
- the command to executeStrandCommand
,
Strand
void instructRoot(io.molr.commons.domain.MissionHandle handle, io.molr.commons.domain.StrandCommand command)
instruct(MissionHandle, Strand, StrandCommand)
method.handle
- a handle representing the mission instance on which the command shall be executedcommand
- the command to execute.