Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Futures/CompletionStage/Async #203

Open
ktalebian opened this issue Mar 23, 2021 · 2 comments
Open

Futures/CompletionStage/Async #203

ktalebian opened this issue Mar 23, 2021 · 2 comments
Assignees
Labels

Comments

@ktalebian
Copy link

How do you create a role where the condition/evaluation is async? For example, I need to make a HTTP request to verify a fact and return the result.

@Clayton7510
Copy link
Collaborator

If you are using something like Spring Boot to accept the HTTP request then you can just create your RuleBook as a Bean and Autowire it into your Controller.

Check out this example: https://github.com/deliveredtechnologies/rulebook/tree/develop/rulebook-examples/helloworld-spring-web

@Clayton7510 Clayton7510 self-assigned this May 26, 2021
@ktalebian
Copy link
Author

ktalebian commented Jun 22, 2021

@Clayton7510 I'm not sure how this applies to my original question. The rule itself needs to be async. In the link you provided, the when condition is still sync https://github.com/deliveredtechnologies/rulebook/blob/develop/rulebook-examples/helloworld-spring-web/src/main/java/com/example/rulebook/helloworld/HelloSpringRule.java

Basically, instead of

@When
public boolean when() {
  return hello != null;
}

I need

@When
public CompletionStage<boolean> when() {
  return getRequest().thenApply(result => result != null);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants