duankuaizhe8257 2016-09-16 21:31
浏览 202

带有微服务间数据传输的Go-kit真实示例

I try to work with go-kit (gokit.io) and to build real-work application with it. I look through examples. These examples are great. But I do not understand how to do services to service communications / data transfers in go-kit framework.

I can see "real-world" shipping app, but I do not understand how it could be "real world" micro-services. I can see in sources that, for example, they build the booking service just passing foreign repositories into service

type service struct {
    cargoRepository         cargo.Repository
    locationRepository      location.Repository
    routingService          routing.Service
    handlingEventRepository cargo.HandlingEventRepository
}

and later they get data from repositories (this repository belongs to foreign micro-service) just calling the method:

locationRepository.Find(...)

Could someone please explain me:

  • how to build micro-service to micro-service communications in go-kit framework? Just show me the way / pattern, please. I do not understand it at all.

I see it as they just share direct access to data. But in real world micro-services, I expected that micro-services will communicate to each other to get needed data. And I do not understand how to do it in go-kit framework.

  • 写回答

1条回答 默认 最新

  • douye2572 2017-03-09 11:45
    关注

    I'm the author of the shipping example. Sorry for not seeing your question earlier.

    This particular example needs a bit of explanation. It is an example based on tactical patterns from Domain Driven Design, which means that we need to understand what we are talking about when we're referring to a service.

    There are application services that deal with the use cases offered by the application, e.g. booking.Service. There are domain services that reside in the domain layer and provides your domain with concepts that aren't necessarily bound to a domain object. In the shipping example, routing.Service is a domain service whose implementation actually queries another application, in this case it talks to this routing service.

    Application and domain services are merely ways of organizing our code. Putting it differently, these services communicate within a process, while microservices typically communicate over a network using some form of common transport, e.g. JSON, gRPC and so on.

    Coming back to your question, what I believe you are looking for is the implementation of the routing.Service which you can find here.

    The proxy service used here is explained under Client-side endpoints on this page, and is used to make requests from your application to another.

    If you want more detail, I wrote a blog post on the subject a while ago.

    评论

报告相同问题?

悬赏问题

  • ¥15 yolov8边框坐标
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂