Skip to content

Commit

Permalink
Add API to sdk-testing to mount workflows. (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
slinkydeveloper authored Feb 12, 2024
1 parent b05c93d commit 5e4c94a
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import dev.restate.sdk.common.BlockingService;
import dev.restate.sdk.common.NonBlockingService;
import dev.restate.sdk.common.ServiceAdapter;
import dev.restate.sdk.http.vertx.RestateHttpEndpointBuilder;
import io.grpc.ServerInterceptor;
import java.util.HashMap;
Expand Down Expand Up @@ -77,6 +78,47 @@ public RestateRunnerBuilder withService(
return this;
}

/**
* Add a Restate service to the endpoint. This will automatically discover the adapter based on
* the class name. You can provide the adapter manually using {@link #with(Object,
* ServiceAdapter)}
*/
public RestateRunnerBuilder with(Object service) {
this.endpointBuilder.with(service);
return this;
}

/**
* Add a Restate service to the endpoint, specifying the {@code executor} where to run the service
* code. This will automatically discover the adapter based on the class name. You can provide the
* adapter manually using {@link #with(Object, ServiceAdapter, Executor)}
*
* <p>You can run on virtual threads by using the executor {@code
* Executors.newVirtualThreadPerTaskExecutor()}.
*/
public RestateRunnerBuilder with(Object service, Executor executor) {
this.endpointBuilder.with(service, executor);
return this;
}

/** Add a Restate service to the endpoint, specifying an adapter. */
public <T> RestateRunnerBuilder with(T service, ServiceAdapter<T> adapter) {
this.endpointBuilder.with(service, adapter);
return this;
}

/**
* Add a Restate service to the endpoint, specifying the {@code executor} where to run the service
* code.
*
* <p>You can run on virtual threads by using the executor {@code
* Executors.newVirtualThreadPerTaskExecutor()}.
*/
public <T> RestateRunnerBuilder with(T service, ServiceAdapter<T> adapter, Executor executor) {
this.endpointBuilder.with(service, adapter, executor);
return this;
}

public ManualRestateRunner buildManualRunner() {
return new ManualRestateRunner(
this.endpointBuilder.build(),
Expand Down

0 comments on commit 5e4c94a

Please sign in to comment.