-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Introduce @Cancellable annotation for Quarkus REST
- Loading branch information
Showing
6 changed files
with
122 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/Cancellable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.jboss.resteasy.reactive.server; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import java.util.concurrent.CompletionStage; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
|
||
/** | ||
* Used on a method that returns a single item async return type (such as {@link Uni} or {@link CompletionStage or Kotlin | ||
* suspend function}) | ||
* to control whether to cancel the subscription to the result if the connection is closed before the result is ready. | ||
* By default, Quarkus will cancel the subscription | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.METHOD, ElementType.TYPE }) | ||
public @interface Cancellable { | ||
|
||
boolean value() default true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...ain/java/org/jboss/resteasy/reactive/server/spi/AbstractCancellableServerRestHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.jboss.resteasy.reactive.server.spi; | ||
|
||
public abstract class AbstractCancellableServerRestHandler implements ServerRestHandler { | ||
|
||
// make mutable to allow for bytecode serialization | ||
private boolean cancellable; | ||
|
||
public boolean isCancellable() { | ||
return cancellable; | ||
} | ||
|
||
public void setCancellable(boolean cancellable) { | ||
this.cancellable = cancellable; | ||
} | ||
} |