官术网_书友最值得收藏!

How to do it...

Decomposing your monolith by business capability is a process. These steps can be carried out in parallel for each new service you identify a need for, but you may want to start with one service and apply the lessons you learn to subsequent efforts:

  1. Identify a business capability that is currently provided by your monolith. This will be the target for our first service. Ideally this business capability is something that has some focus on the roadmap you worked on in the previous recipe and ownership can be given to one of your newly created teams. Let's use our fictional photo messaging service as an example and assume we'll start with the ability to upload and display media as our first identified business capability. This functionality is currently implemented as a single model and controller in your Ruby on Rails monolith:
  1. In the preceding screenshot, AttachmentsController has four methods (called actions in Ruby on Rails lingo), which roughly correspond to the create, retrieve, update, delete (CRUD) operations you want to perform on an Attachment resource. We don't strictly need it, and so will omit the update action. This maps very nicely to a RESTful service, so you can design, implement, and deploy a microservice with the following API:
POST /attachments
GET /attachments/:id
DELETE /attachments/:id
  1. With the new microservice deployed (migrating data is discussed in a later recipe), you can now begin modifying client code paths to use the new service. You can begin by replacing the code in the AttachmentsController action's methods to make an HTTP request to our new microservice. Techniques for doing this are covered in the Evolving your monolith into services recipe later in this chapter.
主站蜘蛛池模板: 科技| 泰安市| 洪湖市| 鄂伦春自治旗| 靖安县| 鄢陵县| 昭平县| 龙川县| 上饶县| 平乡县| 拉孜县| 汉寿县| 浑源县| 肃南| 葫芦岛市| 荥经县| 廊坊市| 驻马店市| 泸西县| 汝城县| 巴中市| 双桥区| 河北区| 潜山县| 凤冈县| 吉林市| 长治县| 称多县| 和静县| 子长县| 巴林右旗| 崇左市| 广南县| 陆河县| 永寿县| 灵寿县| 紫金县| 东方市| 从化市| 吉水县| 长治市|