ParamType - The command parameter typeResultType - The command result typepublic class ObservableCommandManager<ParamType,ResultType> extends Object implements AutoCloseable
| Constructor and Description |
|---|
ObservableCommandManager(@NonNull ObservableCommandTaskRunner taskRunner,
@NonNull RunnableCommandTask<ParamType,ResultType> task)
Constructor
|
ObservableCommandManager(@NonNull ObservableCommandTaskRunner taskRunner,
@NonNull RunnableCommandTask<ParamType,ResultType> task,
Duration lifeTimeOfCommandExecution)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
ObservableCommandWrapper<ParamType,ResultType> |
addCommand(ParamType param,
@NonNull StreamObserver<SiLAFramework.CommandConfirmation> observer)
Add a command to the manager
|
void |
close()
Close all resources owned by the manager
After this call the manager won't be usable anymore
|
ObservableCommandWrapper<ParamType,ResultType> |
get(SiLAFramework.CommandExecutionUUID executionId)
Retrieve a command from the manager
|
ObservableCommandWrapper<ParamType,ResultType> |
get(@NonNull UUID executionId)
Retrieve a command from the manager
|
void |
remove(@NonNull UUID executionId)
Remove a command from the manager
|
public ObservableCommandManager(@NonNull
@NonNull ObservableCommandTaskRunner taskRunner,
@NonNull
@NonNull RunnableCommandTask<ParamType,ResultType> task)
taskRunner - The runnertask - The task that each commands will run
Commands will never expire unless removed manuallypublic ObservableCommandManager(@NonNull
@NonNull ObservableCommandTaskRunner taskRunner,
@NonNull
@NonNull RunnableCommandTask<ParamType,ResultType> task,
@Nullable
Duration lifeTimeOfCommandExecution)
taskRunner - The runnertask - The task that each commands will runlifeTimeOfCommandExecution - The duration after which a command can be removed from the manager
If null the commands will never expire unless removed manuallypublic ObservableCommandWrapper<ParamType,ResultType> addCommand(@NonNull ParamType param, @NonNull @NonNull StreamObserver<SiLAFramework.CommandConfirmation> observer) throws StatusRuntimeException
param - The command parameterobserver - The command confirmation stream observer of the commandStatusRuntimeExceptionpublic ObservableCommandWrapper<ParamType,ResultType> get(@NonNull SiLAFramework.CommandExecutionUUID executionId) throws StatusRuntimeException
executionId - The command identifierStatusRuntimeException - if the command does not existpublic ObservableCommandWrapper<ParamType,ResultType> get(@NonNull @NonNull UUID executionId) throws StatusRuntimeException
executionId - The command identifierStatusRuntimeException - if the command does not existpublic void close()
close in interface AutoCloseablepublic void remove(@NonNull
@NonNull UUID executionId)
Copyright © 2022 SiLA Java Developers. All rights reserved.