Package csw.command.api.javadsl
Interface ICommandService
public interface ICommandService
A Command Service API of a csw component. This model provides method based APIs for command interactions with a component.
-
Method Summary
Modifier and TypeMethodDescriptiononeway
(ControlCommand controlCommand) Send a command as a Oneway and get aCommandResponse.OnewayResponse
as a Future.onewayAndMatch
(ControlCommand controlCommand, StateMatcher stateMatcher) Submit a command and match the published state from the component using aStateMatcher
.Query for the result of a long running command which was sent as Submit to get aCommandResponse.SubmitResponse
as a FuturequeryFinal
(Id commandRunId, akka.util.Timeout timeout) Query for the final result of a long running command which was sent as Submit to get aCommandResponse.SubmitResponse
as a Futuresubmit
(ControlCommand controlCommand) Submit a command and return after first phase.submitAllAndWait
(List<ControlCommand> submitCommands, akka.util.Timeout timeout) Submit multiple commands and get a Source ofCommandResponse.SubmitResponse
for all commands.submitAndWait
(ControlCommand controlCommand, akka.util.Timeout timeout) Submit a command and wait for the final result if it was successfully validated asStarted
to get a finalCommandResponse.SubmitResponse
as a Futureakka.stream.javadsl.Source<CurrentState,
msocket.api.Subscription> Subscribe to all the current states of a component corresponding to theAkkaLocation
of the componentmsocket.api.Subscription
subscribeCurrentState
(Consumer<CurrentState> callback) Subscribe to the current state of a component corresponding to theAkkaLocation
of the componentakka.stream.javadsl.Source<CurrentState,
msocket.api.Subscription> subscribeCurrentState
(Set<StateName> names) Subscribe to the current state of a component corresponding to theAkkaLocation
of the componentmsocket.api.Subscription
subscribeCurrentState
(Set<StateName> names, Consumer<CurrentState> callback) Subscribe to the current state of a component corresponding to theAkkaLocation
of the componentvalidate
(ControlCommand controlCommand) Send a Validate command and get ValidateResponse as a Future.
-
Method Details
-
oneway
Send a command as a Oneway and get aCommandResponse.OnewayResponse
as a Future. The CommandResponse can be a response of validation (Accepted, Invalid) or a Locked response.- Parameters:
controlCommand
- theControlCommand
payload- Returns:
- a CommandResponse as a Future value
-
onewayAndMatch
CompletableFuture<CommandResponse.MatchingResponse> onewayAndMatch(ControlCommand controlCommand, StateMatcher stateMatcher) Submit a command and match the published state from the component using aStateMatcher
. If the match is successful aCompleted
response is provided as a future. In case of a failure or unmatched state,Error
CommandResponse is provided as a Future.- Parameters:
controlCommand
- theControlCommand
payloadstateMatcher
- the StateMatcher implementation for matching received state against a demand state- Returns:
- a MatchingResponse as a Future value
-
query
Query for the result of a long running command which was sent as Submit to get aCommandResponse.SubmitResponse
as a Future- Parameters:
commandRunId
- the runId of the command for which response is required- Returns:
- a CommandResponse as a Future value
-
queryFinal
CompletableFuture<CommandResponse.SubmitResponse> queryFinal(Id commandRunId, akka.util.Timeout timeout) Query for the final result of a long running command which was sent as Submit to get aCommandResponse.SubmitResponse
as a Future- Parameters:
commandRunId
- the runId of the command for which response is requiredtimeout
- (undocumented)- Returns:
- a CommandResponse as a Future value
-
submit
Submit a command and return after first phase. If it returns asStarted
get a finalCommandResponse.SubmitResponse
as a Future with queryFinal.- Parameters:
controlCommand
- theControlCommand
payload- Returns:
- a CommandResponse as a Future value
-
submitAllAndWait
CompletableFuture<List<CommandResponse.SubmitResponse>> submitAllAndWait(List<ControlCommand> submitCommands, akka.util.Timeout timeout) Submit multiple commands and get a Source ofCommandResponse.SubmitResponse
for all commands. The CommandResponse can be a response of validation (Accepted, Invalid) or a final Response. In case of response asAccepted
, final CommandResponse can be obtained by usingsubscribe
API.- Parameters:
submitCommands
- the set ofControlCommand
payloadstimeout
- (undocumented)- Returns:
- a Source of CommandResponse as a stream of CommandResponses for all commands
-
submitAndWait
CompletableFuture<CommandResponse.SubmitResponse> submitAndWait(ControlCommand controlCommand, akka.util.Timeout timeout) Submit a command and wait for the final result if it was successfully validated asStarted
to get a finalCommandResponse.SubmitResponse
as a Future- Parameters:
controlCommand
- theControlCommand
payloadtimeout
- (undocumented)- Returns:
- a CommandResponse as a Future value
-
subscribeCurrentState
akka.stream.javadsl.Source<CurrentState,msocket.api.Subscription> subscribeCurrentState()Subscribe to all the current states of a component corresponding to theAkkaLocation
of the component- Returns:
- a stream of current states with Subscription as the materialized value which can be used to stop the subscription
-
subscribeCurrentState
akka.stream.javadsl.Source<CurrentState,msocket.api.Subscription> subscribeCurrentState(Set<StateName> names) Subscribe to the current state of a component corresponding to theAkkaLocation
of the component- Parameters:
names
- subscribe to states which have any of the provided value for name. If no states are provided, all the current states will be received.- Returns:
- a stream of current states with Subscription as the materialized value which can be used to stop the subscription
-
subscribeCurrentState
Subscribe to the current state of a component corresponding to theAkkaLocation
of the componentNote that callbacks are not thread-safe on the JVM. If you are doing side effects/mutations inside the callback, you should ensure that it is done in a thread-safe way inside an actor.
- Parameters:
callback
- the action to be applied on the CurrentState element received as a result of subscription- Returns:
- a Subscription to stop the subscription
-
subscribeCurrentState
msocket.api.Subscription subscribeCurrentState(Set<StateName> names, Consumer<CurrentState> callback) Subscribe to the current state of a component corresponding to theAkkaLocation
of the componentNote that callbacks are not thread-safe on the JVM. If you are doing side effects/mutations inside the callback, you should ensure that it is done in a thread-safe way inside an actor.
- Parameters:
names
- subscribe to only those states which have any of the the provided value for namecallback
- the action to be applied on the CurrentState element received as a result of subscription- Returns:
- a Subscription to stop the subscription
-
validate
Send a Validate command and get ValidateResponse as a Future. The ValidateResponse can be of type Accepted, Invalid or Locked.- Parameters:
controlCommand
- theControlCommand
payload- Returns:
- a ValidateResponse as a Future value
-