使用 go micro 搭建微服务接口的经验教训

一、问题

运行micro服务时出现Rigistry consul not found问题,导致微服务运行不成功

二、原因

  • 个人原因:
    学习教程时在安装 protoc-gen-micro该工具可以帮助我们快速生成微服务模板代码,
    需要用到go get github.com/micro/protoc-gen-micro
    而我在github上看到的命令是
    go get github.com/micro/protoc-gen-micro/v2,在没有了解v1、v2版本差异的情况下就安装了v2版本,以为版本越新越好,现在想一下确实有些范二了,导致出现如上错误
  • go micro原因:
    micro的最新v2版本不开箱支持consul了,目前consul现在以插件的方式引入。
    官方推荐使用ectd,毕竟ectd现在成为了k8s的默认配置。

    ps: 附上go micro核心开发者的解释:
    We’ve in the past week moved etcd to become one of the default service discovery mechanisms in Micro and will be looking to deprecate Consul in the coming weeks. What does this mean? Well we’ll be moving consul to our community maintained go-plugins repository and focusing on supporting etcd.
    https://medium.com/microhq/deprecating-con...
    ps: 感谢laravel 学院君的解答,他最近会出一门最新的go module 下micro+ectd微服务的教程,欢迎有兴趣的同学去关注。

本作品采用《CC 协议》,转载必须注明作者和本文链接
xugege
讨论数量: 2
taadis

micro/v2 默认内置的是零配置的 mdns, 方便开发. 生产集群环境推荐更推荐使用 etcd 了. :smirk:

4年前 评论

有没有完整点的资料啊

3年前 评论
taadis 3年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!