quarkus-dapr icon indicating copy to clipboard operation
quarkus-dapr copied to clipboard

Introduce to inject DaprClient in the interfaces

Open zhfeng opened this issue 3 years ago • 3 comments

It could be similar with @RegisterRestClient in quarkus. such as

@RegisterDaprClient
public interface someService {
    void invoke(String id);
}

We need to process this annotation with injecting the DaprClient and mapping the method to do invoking.

zhfeng avatar Apr 19 '22 08:04 zhfeng

yes,it need two annotations like @RegisterRestClient and @RestClient

i proposed that they are @RegisterDaprInvokeClient and @DaprInvokeClient,such as

@Path("/dapr-invoke-client")
@RegisterDaprInvokeClient
public interface ExtensionsService {

    @GET
    String getById(@QueryParam String id);

}

@ApplicationScoped
public class DaprRestClient2ExtensionResource {

    @DaprInvokeClient
    ExtensionsService extensionsService;

}

naah69 avatar Apr 20 '22 04:04 naah69

Why it needs @Path here ? is it refer to javax.ws.rs.Path?

The dapr-client does the http invokings like JaxRS style? @aosky can you provide a typical example of dapr http usage?

zhfeng avatar Apr 20 '22 05:04 zhfeng

dapr invoke is a kind of rpc,so it need @Path. below is method of dapr client ,it is too original,we need package it such as quarkus-rest-client

    public <T> T invokeMethod(String appId, String methodName, Object data, HttpExtension httpExtension,
            Map<String, String> metadata, TypeRef<T> type) {
        return daprClient.invokeMethod(appId, methodName, data, httpExtension, metadata, type).block();
    }

naah69 avatar Apr 20 '22 05:04 naah69