zhengyangyong commented on a change in pull request #47: General development dir translation and include img URL: https://github.com/apache/incubator-servicecomb-docs/pull/47#discussion_r212512688
########## File path: java-chassis-reference/en_US/general-development/context.md ########## @@ -1,36 +1,36 @@ -# 使用Context传递控制消息 +# Delivery Context Control Message -ServiceComb提供了Context在微服务之间传递数据。Context是key/value对,只能够使用String类型的数据。由于Context会序列化为json格式并通过HTTP Header传递,因此也不支持ASCII之外的字符,其他字符需要开发者先自行编码再传递。Context在一次请求中,会在请求链上传递,不需要重新设置。[access log](../build-provider/access-log-configuration.md)的trace id等功能都基于这个特性实现的。 +ServiceComb provides a Context to delivery data between microservices. Context is a key/value pair and can only use data of type String. Since the Context is serialized into the Json format and passed through the HTTP header, characters other than ASCII are not supported. Other characters require the developer to encode and pass the code. The Context is passed on the request chain in a single request and does not need to be reset. The functions such as trace id of [access log](../build-provider/access-log-configuration.md) are implemented based on this feature. -## 场景描述 -* 在认证场景,Edge Service认证通过以后,需要将会话ID、用户名称等信息传递给微服务,实现鉴权等逻辑 -* 灰度发布场景,需要结合自定义的tag实现引流,tag信息需要传递给微服务 +## Scene Description +* In the authentication scenario, after the Edge Service authentication is passed, the session ID, username, and other information need to be passed to the microservice to implement authentication and other logic. +* Grayscale publishing scenarios, need to be combined with custom tags to achieve drainage, tag information needs to be passed to the microservices -## 使用参考 +## Use Reference -* 在Hanlder中获取和设置Context +* Get and set the Context in Handler -Handler包含了Invocation对象,可以直接调用invocation.addContext和invocation.getContext设置。 +The Handler contains the Invocation object, which can be called directly in the invocation.addContext and invocation.getContext settings. -* 在服务接口中获取Context +* Get Context in the service interface -通过接口注入 +Inject through the interface ``` public Response cseResponse(InvocationContext c1) ``` -或者 +or ``` ContextUtils.getInvocationContext() ``` -* 在Edge Service中设置Context +* Set the Context in the Edge Service -通过重载EdgeInvocation +By overloading EdgeInvocation Review comment: overloading -> override ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
