Class Matcher
- java.lang.Object
-
- csw.command.client.models.matchers.Matcher
-
public class Matcher extends java.lang.Object
The matcher uses the matching definition as provided byStateMatcher
to match against the state generated by subscribing a source of that stateparam: currentStateSource source of the state which needs to be matched against the current state specified in state matcher param: stateMatcher the matcher definition to execute
-
-
Constructor Summary
Constructors Constructor Description Matcher(akka.actor.typed.ActorRef<ComponentCommonMessage.ComponentStateSubscription> currentStateSource, StateMatcher stateMatcher, scala.concurrent.ExecutionContext ec, akka.stream.Materializer mat)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<MatcherResponse>
jStart()
Start the matching process from Java applicationscala.concurrent.Future<MatcherResponse>
start()
Start the matching processvoid
stop()
Abort the stream of subscribed state in case matching is no longer required.
-
-
-
Constructor Detail
-
Matcher
public Matcher(akka.actor.typed.ActorRef<ComponentCommonMessage.ComponentStateSubscription> currentStateSource, StateMatcher stateMatcher, scala.concurrent.ExecutionContext ec, akka.stream.Materializer mat)
-
-
Method Detail
-
jStart
public java.util.concurrent.CompletableFuture<MatcherResponse> jStart()
Start the matching process from Java application- Returns:
- the result of matching as a CompletableFuture of MatcherResponse
-
start
public scala.concurrent.Future<MatcherResponse> start()
Start the matching process- Returns:
- the result of matching as a Future value of MatcherResponse
-
stop
public void stop()
Abort the stream of subscribed state in case matching is no longer required. Eg. when composing operations in command execution, the matching was started before knowing the actual result of validation and the validation failed.val matcherResponseF: Future[MatcherResponse] = matcher.start val eventualCommandResponse: Future[CommandResponse] = async { val initialResponse = await(assemblyComponent.oneway(setupWithMatcher)) initialResponse match { case _: Accepted ⇒ val matcherResponse = await(matcherResponseF) matcherResponse match { case MatchCompleted ⇒ Completed(setupWithMatcher.runId) case MatchFailed(ex) ⇒ Error(setupWithMatcher.runId, ex.getMessage) } case invalid: Invalid ⇒ matcher.stop() invalid case x ⇒ x }
-
-