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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<CommandResponse.OnewayResponse>
oneway(ControlCommand controlCommand)
Send a command as a Oneway and get aCommandResponse.OnewayResponse
as a Future.java.util.concurrent.CompletableFuture<CommandResponse.MatchingResponse>
onewayAndMatch(ControlCommand controlCommand, StateMatcher stateMatcher)
Submit a command and match the published state from the component using aStateMatcher
.java.util.concurrent.CompletableFuture<CommandResponse.SubmitResponse>
query(Id commandRunId)
Query for the result of a long running command which was sent as Submit to get aCommandResponse.SubmitResponse
as a Futurejava.util.concurrent.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 Futurejava.util.concurrent.CompletableFuture<CommandResponse.SubmitResponse>
submit(ControlCommand controlCommand)
Submit a command and return after first phase.java.util.concurrent.CompletableFuture<java.util.List<CommandResponse.SubmitResponse>>
submitAllAndWait(java.util.List<ControlCommand> submitCommands, akka.util.Timeout timeout)
Submit multiple commands and get a Source ofCommandResponse.SubmitResponse
for all commands.java.util.concurrent.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 Futureakka.stream.javadsl.Source<CurrentState,msocket.api.Subscription>
subscribeCurrentState()
Subscribe to all the current states of a component corresponding to theAkkaLocation
of the componentmsocket.api.Subscription
subscribeCurrentState(java.util.function.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(java.util.Set<StateName> names)
Subscribe to the current state of a component corresponding to theAkkaLocation
of the componentmsocket.api.Subscription
subscribeCurrentState(java.util.Set<StateName> names, java.util.function.Consumer<CurrentState> callback)
Subscribe to the current state of a component corresponding to theAkkaLocation
of the componentjava.util.concurrent.CompletableFuture<CommandResponse.ValidateResponse>
validate(ControlCommand controlCommand)
Send a Validate command and get ValidateResponse as a Future.
-
-
-
Method Detail
-
oneway
java.util.concurrent.CompletableFuture<CommandResponse.OnewayResponse> oneway(ControlCommand controlCommand)
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
java.util.concurrent.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
java.util.concurrent.CompletableFuture<CommandResponse.SubmitResponse> query(Id commandRunId)
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
java.util.concurrent.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
java.util.concurrent.CompletableFuture<CommandResponse.SubmitResponse> submit(ControlCommand controlCommand)
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
java.util.concurrent.CompletableFuture<java.util.List<CommandResponse.SubmitResponse>> submitAllAndWait(java.util.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
java.util.concurrent.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(java.util.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
msocket.api.Subscription subscribeCurrentState(java.util.function.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:
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(java.util.Set<StateName> names, java.util.function.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
java.util.concurrent.CompletableFuture<CommandResponse.ValidateResponse> validate(ControlCommand controlCommand)
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
-
-