Code Monkey home page Code Monkey logo

Comments (7)

ystyle avatar ystyle commented on June 3, 2024 1

Got it, so both InvokeServiceWithContent and InvokeService defaulting to POST does not allow you to set other verbs on the request. OK, I changed the title of this issue to "Parameterize request method verb on service invocation" and will classify it as a bug.

Message: &v1.InvokeRequest{
   Method: method,
   HttpExtension: &v1.HTTPExtension{
      Verb: v1.HTTPExtension_POST, // parameterize 
   },
}

I tested it and it is available after adding parameters

from go-sdk.

ystyle avatar ystyle commented on June 3, 2024

k8s cluster app has the same issue:

deploy 2 app in k8s.

  • app1: /test

  • app2: /test2 and use sdk invoke app1 /test

    res, err := client.InvokeService(ctx, "myapp.myns", "test")
    

forward app2 port on local:

 kubectl port-forward svc/myapp2 50001:50001 3500:3500 8080:8080 -n myns

call app2/test2 use curl:

ystyle@Archlinux  ~  curl -v 127.0.0.1:8080/test2                                                   
*   Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET /test2 HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.73.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Set-Cookie: go_session_id=MGU1OTEzYTEtNmEzOC00NzUwLWE0YmUtMTJmZjE4ODU1ZTU2.a8b2c31a9c5286837d560cb3ac3bd85fdc6371b4; Path=/; Expires=Wed, 16 Dec 2020 03:48:01 GMT; Max-Age=604800; HttpOnly
< Date: Wed, 09 Dec 2020 03:48:01 GMT
< Content-Length: 87
< 
* Connection #0 to host 127.0.0.1 left intact
{"code":-1,"msg":"error invoking service: rpc error: code = NotFound desc = Not Found"}%                                                                          ystyle@Archlinux  ~

from go-sdk.

ystyle avatar ystyle commented on June 3, 2024

go-sdk can't set HttpExtension which causes the above problems, this is available on java sdk:

https://github.com/dapr/java-sdk/blob/master/examples/src/main/java/io/dapr/examples/invoke/http/InvokeClient.java#L35-L37

**
   * Invoke a service method, using serialization.
   *
   * @param appId         The Application ID where the service is.
   * @param method        The actual Method to be call in the application.
   * @param request       The request to be sent to invoke the service, use byte[] to skip serialization.
   * @param httpExtension Additional fields that are needed if the receiving app is listening on
   *                      HTTP, {@link io.dapr.client.domain.HttpExtension#NONE} otherwise.
   * @param metadata      Metadata (in GRPC) or headers (in HTTP) to be sent in request.
   * @param type          The Type needed as return for the call.
   * @param <T>           The Type of the return, use byte[] to skip serialization.
   * @return A Mono Plan of type T.
   */
  <T> Mono<T> invokeService(String appId, String method, Object request, HttpExtension httpExtension,
                            Map<String, String> metadata, TypeRef<T> type);

from go-sdk.

mchmarny avatar mchmarny commented on June 3, 2024

@ystyle can you elaborate more on the actual issue here? Mainly, are these 3 separate issues or all three are part of this one issue?

from go-sdk.

ystyle avatar ystyle commented on June 3, 2024

@ystyle can you elaborate more on the actual issue here? Mainly, are these 3 separate issues or all three are part of this one issue?

The problem is caused by the absence of httpExtension, and the existing restful interface cannot be rewritten

gosdk default http method is POST, and can not set to other

from go-sdk.

mchmarny avatar mchmarny commented on June 3, 2024

Got it, so both InvokeServiceWithContent and InvokeService defaulting to POST does not allow you to set other verbs on the request. OK, I changed the title of this issue to "Parameterize request method verb on service invocation" and will classify it as a bug.

Message: &v1.InvokeRequest{
   Method: method,
   HttpExtension: &v1.HTTPExtension{
      Verb: v1.HTTPExtension_POST, // parameterize 
   },
}

from go-sdk.

mchmarny avatar mchmarny commented on June 3, 2024

@ystyle PR under review, once lands you will have to import from HEAD to use it until we make a new release.

from go-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.