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 ServiceOptions to Service #5071

Open
ikhoon opened this issue Jul 25, 2023 · 1 comment · May be fixed by #5574
Open

Add ServiceOptions to Service #5071

ikhoon opened this issue Jul 25, 2023 · 1 comment · May be fixed by #5574

Comments

@ikhoon
Copy link
Contributor

ikhoon commented Jul 25, 2023

Currently, there is no way to set the default options for a specific service.
Users should override the default options for a service when it is bound to a server.

public final class ServiceBindingBuilder extends AbstractServiceBindingBuilder {

If we provide a way to provide the default options from a service, users can define a sensible default option for certain services when implementing the service.

interface HttpService {

  default ServiceOptions defaultOptions() {
    return ServiceOptions.of();
  }
}

class WebSocketService extends HttpService {
    @Override
    default ServiceOptions defaultOptions() {
       return WEB_SOCKET_DEFAULT_OPTIONS;
    }
}

// ServiceConfigBuilder

if (service.option() != ServiceOptions.of()) {
   // override the default values with service.options().
}

We can also define an annotation like @ServiceOption to inject the values to ServiceOptions for annotated services.

public class MyService {

  @ServiceOption(
     maxRequestLength = 1_000_000, // 100 MB
     responseTimeoutMillis = 120_000, // 2 minutes
     ...
  )
  @Post("/upload")
  public CompletableFuture<Result> upload(MultipartFile file) { ... }

  @ServiceOption(
     responseTimeoutMillis = 0, // disable the timeout
     verboseResponse = true,
     ...
  )
  @Get("/upload")
  public HttpResponse videoStreaming(String filename) { ... }
  
}
@seonWKim seonWKim linked a pull request Apr 7, 2024 that will close this issue
@seonWKim
Copy link
Contributor

seonWKim commented Apr 7, 2024

Hi, @ikhoon. I've made a PR on this issue 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants