Skip to content

Commit 01fb547

Browse files
Robert Pospisiljmartisk
authored andcommitted
add run on virtual threads
1 parent 7715de6 commit 01fb547

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

common/schema-builder/src/main/java/io/smallrye/graphql/schema/Annotations.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,8 @@ private static Map<DotName, AnnotationInstance> getAnnotationsWithFilter(org.jbo
581581
// SmallRye Common Annotations
582582
public static final DotName BLOCKING = DotName.createSimple("io.smallrye.common.annotation.Blocking");
583583
public static final DotName NON_BLOCKING = DotName.createSimple("io.smallrye.common.annotation.NonBlocking");
584+
public static final DotName RUN_ON_VIRTUAL_THREAD = DotName
585+
.createSimple("io.smallrye.common.annotation.RunOnVirtualThread");
584586

585587
// SmallRye GraphQL Annotations (Experimental)
586588
public static final DotName TO_SCALAR = DotName.createSimple("io.smallrye.graphql.api.ToScalar"); // TODO: Remove

common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/OperationCreator.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,17 @@ private Execute getExecution(Annotations annotationsForMethod, Annotations annot
326326
return Execute.BLOCKING;
327327
} else if (annotationsForMethod.containsOneOfTheseAnnotations(Annotations.NON_BLOCKING)) {
328328
return Execute.NON_BLOCKING;
329+
} else if (annotationsForMethod.containsOneOfTheseAnnotations(Annotations.RUN_ON_VIRTUAL_THREAD)) {
330+
return Execute.RUN_ON_VIRTUAL_THREAD;
329331
}
330332

331333
// then check annotation on class
332334
if (annotationsForClass.containsOneOfTheseAnnotations(Annotations.BLOCKING)) {
333335
return Execute.BLOCKING;
334336
} else if (annotationsForClass.containsOneOfTheseAnnotations(Annotations.NON_BLOCKING)) {
335337
return Execute.NON_BLOCKING;
338+
} else if (annotationsForClass.containsOneOfTheseAnnotations(Annotations.RUN_ON_VIRTUAL_THREAD)) {
339+
return Execute.RUN_ON_VIRTUAL_THREAD;
336340
}
337341

338342
// lastly use default based on return type

common/schema-model/src/main/java/io/smallrye/graphql/schema/model/Execute.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
public enum Execute {
99
BLOCKING,
1010
NON_BLOCKING,
11-
DEFAULT
11+
DEFAULT,
12+
RUN_ON_VIRTUAL_THREAD
1213
}

0 commit comments

Comments
 (0)