Giter VIP home page Giter VIP logo

Comments (7)

SkyWingZhang avatar SkyWingZhang commented on June 27, 2024

`XZ06WO(OMWDEMV~N0P}C_N

from stack-rpc-tutorials.

printfcoder avatar printfcoder commented on June 27, 2024

不可以,微服务的调用范式一般是命名空间(或者包名)+ 方法签名
micro call也是在预先知道服务的命名空间与方法名的情况下才能调用服务。
如果要抛开空间和方法签名直接调用,可以使用restful风格的micro api网关把通用包要调用的服务隔离起来,不过这个就撕裂了微服务之间的直接通信的桥梁。
能否把具体的场景大概说下?

from stack-rpc-tutorials.

SkyWingZhang avatar SkyWingZhang commented on June 27, 2024

场景:在每个服务启动前(不包括config服务),向config服务请求配置文件,并且我已拥有该config服务的一切资料。。我写一个包,嵌入在每一个服务的main中,我已通过"github.com/micro/go-micro/registry"包向consul注册中心请求到了config服务的ip和端口和方法名和参数。,先在只需像在命令行下micro call那样请求,请指点一下该怎么去请求。

from stack-rpc-tutorials.

SkyWingZhang avatar SkyWingZhang commented on June 27, 2024

39F0F7DE-D47D-4746-89ED-003A7514A8E7
这一段是我根据服务名向注册中心请求回来的服务的方法、参数、还有ip和端口等,转为json格式后我就知道这个服务中有什么方法,请求需要什么参数,这样我就可以完成独立封闭情况下去开发,而不用跟同事交流,我想,这也方便保密。我根据这段json格式的数据就可以自定义出请求参数和返回参数的结构体。现在问题是,如何去请求,micro框架中是否有根据ip和端口、请求的方法名、请求的结构体参数、返回的结构体数据,便可以call某服务
639B0D28-8D6E-4C1B-AE4E-BC17640A17F8

from stack-rpc-tutorials.

printfcoder avatar printfcoder commented on June 27, 2024

可以尝试Micro Client吧,见使用方法

这样稍微优雅些,不用写一堆Micro中已经有的请求代码

from stack-rpc-tutorials.

SkyWingZhang avatar SkyWingZhang commented on June 27, 2024

好的,非常感谢你的解答。这对我有很大帮助。请问命令行下的micro call源码位于哪里,想研究下怎么是么实现的,感谢

from stack-rpc-tutorials.

printfcoder avatar printfcoder commented on June 27, 2024

不客气,见:https://github.com/micro/micro/blob/master/cli/cli.go#L19

from stack-rpc-tutorials.

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.