Skip to content

Commit 5e4c94a

Browse files
Add API to sdk-testing to mount workflows. (#223)
1 parent b05c93d commit 5e4c94a

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

sdk-testing/src/main/java/dev/restate/sdk/testing/RestateRunnerBuilder.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import dev.restate.sdk.common.BlockingService;
1212
import dev.restate.sdk.common.NonBlockingService;
13+
import dev.restate.sdk.common.ServiceAdapter;
1314
import dev.restate.sdk.http.vertx.RestateHttpEndpointBuilder;
1415
import io.grpc.ServerInterceptor;
1516
import java.util.HashMap;
@@ -77,6 +78,47 @@ public RestateRunnerBuilder withService(
7778
return this;
7879
}
7980

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+
80122
public ManualRestateRunner buildManualRunner() {
81123
return new ManualRestateRunner(
82124
this.endpointBuilder.build(),

0 commit comments

Comments
 (0)