Skip to content

Commit

Permalink
feat: documented future-returning handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
Citymonstret committed Feb 2, 2024
1 parent f17e87c commit a62d6da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions docs/annotations/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ or custom injections.

The annotation may be repeated in order to generate multiple commands from the same method.

The command method may return [`CompletableFuture<Void>`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/CompletableFuture.html)
in which case the execution coordinator will wait for the returned future to complete:

```java
@Command("command")
public CompletableFuture<Void> command() {
return CompletableFuture.supplyAsync(() -> null);
}
```

### Syntax

There are three different parts that make up the command syntax:
Expand Down
7 changes: 6 additions & 1 deletion docs/core/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,12 @@ builder.handler(ctx -> {
You may implement
[`CommandExecutionHandler.FutureCommandExecutionHandler`](https://javadoc.io/doc/org.incendo/cloud-core/latest/org/incendo/cloud/execution/CommandExecutionHandler.FutureCommandExecutionHandler.html)
to have the handler be a future-returning
function. Cloud will wait for the future to complete and will handle any completion exceptions gracefully.
function. Cloud will wait for the future to complete and will handle any completion exceptions gracefully. You may
use the `futureHandler` command builder method to specify a future-returning handler:

```java
builder.futureHandler(ctx -> CompletableFuture.completedFuture(null))
```

You may delegate to other handlers using
[`CommandExecutionHandler.delegatingExecutionHandler`](<https://javadoc.io/doc/org.incendo/cloud-core/latest/org/incendo/cloud/execution/CommandExecutionHandler.html#delegatingExecutionHandler(java.util.List)>).
Expand Down

0 comments on commit a62d6da

Please sign in to comment.