Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API to sdk-testing to mount workflows. #223

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading