You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/08/27 09:01:41 UTC

[incubator-servicecomb-docs] 03/09: update java-chassis-reference/en_US/build-consumer/with-contract.md

This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-docs.git

commit 0a2d3a94f1bcc6ebfddd56deadb10e57c2057f32
Author: DeanLee <li...@huawei.com>
AuthorDate: Tue Aug 21 18:05:18 2018 +0800

    update java-chassis-reference/en_US/build-consumer/with-contract.md
---
 .../en_US/build-consumer/with-contract.md          | 51 ++++++++++------------
 1 file changed, 23 insertions(+), 28 deletions(-)

diff --git a/java-chassis-reference/en_US/build-consumer/with-contract.md b/java-chassis-reference/en_US/build-consumer/with-contract.md
index 3cf5eaa..8e72c10 100644
--- a/java-chassis-reference/en_US/build-consumer/with-contract.md
+++ b/java-chassis-reference/en_US/build-consumer/with-contract.md
@@ -1,16 +1,13 @@
-# 使用服务契约
+# Service Using API Definitions  
+## Scenario
 
-## 场景描述
+When a consumer calls a service from a provider, you need to register a service API definition. You can obtain service API definition from your provider for your consumer in two ways. One is to obtain the service API definition from the provider off-line and manually configure the API definition to the project. Another is to automatically download the service API definition from the service center.
 
-当服务消费者调用服务提供者的服务时,需要注册服务契约。消费者有两种方式获取提供者的服务契约,一种是从服务的提供方离线获取契约文件,手工配置到项目中;另一种是从服务中心自动下载契约。
+## Configuration
 
-## 配置说明
+> You can obtain service API definition in either way, regardless of the development mode of service consumers.
 
-> 说明:服务契约的获取方式与服务消费者的开发方式是无关的,用户可以任意组合使用。
-
-### 配置依赖服务
-
-服务消费者需要在microservice.yaml文件中配置依赖的provider,示例配置如下:
+In the microservice.yaml file, configure a provider for the consumer. The following is an example of the configuration:
 
 ```yaml
 servicecomb:
@@ -20,33 +17,31 @@ servicecomb:
       version-rule: 0.0.1
 ```
 
-> version-rule是版本匹配规则,有四种格式:
+> There are four kind of rule for version-rule:
 >
-> * 精确版本匹配:例如`version-rule: 0.0.1`,表示只匹配版本号为0.0.1的服务提供者
-> * 后续版本匹配:例如`version-rule: 1.0.0+`,表示匹配版本号大于或等于1.0.0的服务提供者
-> * 最新版本:`version-rule: latest`,表示匹配最新版本的服务提供者
-> * 版本范围:例如`1.0.0-2.0.2`,表示匹配版本号在1.0.0至2.0.2之间的服务提供者,包含1.0.0和2.0.2
+> * Accurate Matching Rule: such as `version-rule: 0.0.1`, it indicates that only those  providers whose version is 0.0.1 can be matched.
+> * Later Matching Rule: such as `version-rule: 1.0.0+`, it indicates that those providers whose version is later that 1.0.0 can be matched.
+> * Latest Matching Rule: such as `version-rule: latest`, it indicates that only  those providers whose version number is latest can be matched.
+> * Range Matching Rule: such as`1.0.0-2.0.2`,  it indicates that those provider whose version number is between 1.0.0 and 2.0.2 can be matched, including 1.0.0 and 2.0.2
 >
-> 此配置项默认为`latest`
-
-### 手工配置服务契约
+> The default version rule of version-rule is `latest`.
 
-服务消费者的开发者在线下拿到服务提供者的契约,配置到消费者工程的特定目录下。服务契约在项目中的存放目录与[定义服务契约](/build-provider/define-contract.md)的配置说明部分相同。
+### Manually Configuring Service API Definition
 
-microservice目录下的每一个目录代表一个微服务,微服务目录下的每一个yaml文件代表一个schema契约,文件名就是schemaId。applications目录下存放需要指明appId的服务契约,用于跨app调用等场景。目录结构如下所示:
+After you obtained the API definition of your consumer from the provider, configure it in a specified directory of the consumer project. The directory is the one mentioned in the configuration description [Service Contract](/users/service-contract/).
 
-```
+Each directory under the microservices directory indecates a microservice, and each .yaml file under the jaxrs directory represents a schema API definition. The file name is the schema ID. The service API definitions whose application IDs need to be specified are stored under the applications directory for cross-application calls. The directory structure is as follows:
+```txt
 resources
   - microservices
-      - serviceName            # 微服务名
-          - schemaId.yaml      # schema接口的契约
+      - serviceName            # Microservice name
+          - schemaId.yaml      # Schema API definition
   - applications
-      - appId                  # 应用ID
-          - serviceName        # 微服务名
-              - schemaId.yaml  # schema接口的契约
+      - appId                  # Application ID
+          - serviceName        # Microservice name
+              - schemaId.yaml  # Schema API definition
 ```
 
-### 从服务中心自动下载契约
-
-服务消费者也可以不用显式地将契约存放在项目目录中,当程序启动时,ServiceComb框架会自动根据microservice.yaml文件中配置的服务提供者的微服务名称和版本号,从服务中心自动下载契约信息。
+### Automatically Downloading API Definition from Service Center
 
+If a consumer does not explicitly store the API definition in the project directory, when the application is started, the ServiceComb framework automatically downloads the information about the API definition from the service center based on the provider's microservices name and version configured in microservice.yaml.