|
10 | 10 |
|
11 | 11 | import dev.restate.sdk.common.BlockingService;
|
12 | 12 | import dev.restate.sdk.common.NonBlockingService;
|
| 13 | +import dev.restate.sdk.common.ServiceAdapter; |
13 | 14 | import dev.restate.sdk.http.vertx.RestateHttpEndpointBuilder;
|
14 | 15 | import io.grpc.ServerInterceptor;
|
15 | 16 | import java.util.HashMap;
|
@@ -77,6 +78,47 @@ public RestateRunnerBuilder withService(
|
77 | 78 | return this;
|
78 | 79 | }
|
79 | 80 |
|
| 81 | + /** |
| 82 | + * Add a Restate service to the endpoint. This will automatically discover the adapter based on |
| 83 | + * the class name. You can provide the adapter manually using {@link #with(Object, |
| 84 | + * ServiceAdapter)} |
| 85 | + */ |
| 86 | + public RestateRunnerBuilder with(Object service) { |
| 87 | + this.endpointBuilder.with(service); |
| 88 | + return this; |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * Add a Restate service to the endpoint, specifying the {@code executor} where to run the service |
| 93 | + * code. This will automatically discover the adapter based on the class name. You can provide the |
| 94 | + * adapter manually using {@link #with(Object, ServiceAdapter, Executor)} |
| 95 | + * |
| 96 | + * <p>You can run on virtual threads by using the executor {@code |
| 97 | + * Executors.newVirtualThreadPerTaskExecutor()}. |
| 98 | + */ |
| 99 | + public RestateRunnerBuilder with(Object service, Executor executor) { |
| 100 | + this.endpointBuilder.with(service, executor); |
| 101 | + return this; |
| 102 | + } |
| 103 | + |
| 104 | + /** Add a Restate service to the endpoint, specifying an adapter. */ |
| 105 | + public <T> RestateRunnerBuilder with(T service, ServiceAdapter<T> adapter) { |
| 106 | + this.endpointBuilder.with(service, adapter); |
| 107 | + return this; |
| 108 | + } |
| 109 | + |
| 110 | + /** |
| 111 | + * Add a Restate service to the endpoint, specifying the {@code executor} where to run the service |
| 112 | + * code. |
| 113 | + * |
| 114 | + * <p>You can run on virtual threads by using the executor {@code |
| 115 | + * Executors.newVirtualThreadPerTaskExecutor()}. |
| 116 | + */ |
| 117 | + public <T> RestateRunnerBuilder with(T service, ServiceAdapter<T> adapter, Executor executor) { |
| 118 | + this.endpointBuilder.with(service, adapter, executor); |
| 119 | + return this; |
| 120 | + } |
| 121 | + |
80 | 122 | public ManualRestateRunner buildManualRunner() {
|
81 | 123 | return new ManualRestateRunner(
|
82 | 124 | this.endpointBuilder.build(),
|
|
0 commit comments