rahil-c commented on code in PR #704: URL: https://github.com/apache/incubator-xtable/pull/704#discussion_r2076766407
########## xtable-service/src/main/java/org/apache/xtable/service/ConversionResource.java: ########## @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.xtable.service; + +import org.apache.xtable.service.models.ConvertTableRequest; +import org.apache.xtable.service.models.ConvertTableResponse; + +import io.smallrye.common.annotation.Blocking; +import jakarta.inject.Inject; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; + +@Path("/v1/conversion") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class ConversionResource { + + @Inject ConversionService conversionService; + + @POST + @Path("/table") + @Blocking Review Comment: For Quarkus, I am bringing one of its rest dependencies know as rest-easy-reactive: https://quarkus.io/guides/rest#execution-model-blocking-non-blocking ``` Quarkus REST is implemented using two main thread types: Event-loop threads: which are responsible, among other things, for reading bytes from the HTTP request and writing bytes back to the HTTP response Worker threads: they are pooled and can be used to offload long-running operations ``` In general the endpoints are ran on these event loop threads to handle the incoming requests, however these are meant for lightweight operations, if an operation is going to do something more intensive that will take longer time to handle then the recommendation is to use `@Blocking` which will spin the operation on its own worker thread. https://quarkus.io/blog/resteasy-reactive-faq/ ``` Although RESTEasy Reactive was built from the ground up to do non-blocking IO and serve requests from the event loop threads (thus avoiding the needless usage of worker pool threads) it can effortlessly work with blocking IO and any piece of code that provides a blocking API (such as Hibernate) without blocking the event loop. The only thing you have to do is add @Blocking on your endpoint method or class. That’s it! If you use @Blocking you are back to the regular dispatching mechanism: a worker thread is used to execute your method. Although the absolute highest throughput is achieved when an endpoint method is non-blocking (that is the HTTP request is served completely from the event loop thread), great performance can nonetheless be achieved even when @Blocking is used. ``` Since this endpoint is essentially calling conversion controller `sync` and reading and writing to cloud storage in my mind it made sense for annotate with `@Blocking`, (note this should spawn a worked thread to handle this converison, but still allow other network requests to be served and not blocked, i can do a manual test to confirm this as well). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@xtable.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org