Hi, community. 
This issue is related to this [pull 
request](https://github.com/apache/incubator-dubbo/pull/2228).You can see more 
details about this feature. A simple and incomplete `TagRouter` has merged into 
dubbo v2.7.0-snapshot,in this issue,i will introduce what problem did it 
solve,while i want to refer to your opinion and proposal, decide the final 
behavior of  `TagRouter` .

### What is TagRouter

TagRouter is a new implement of Router interface, other exsiting Router : 
`ConditionRouter`, `ScriptRouter`, `FileRouter`.

It makes any request can carry a `request.tag` and any service belong to a 
certain `tag`
Tag will affect the default route behavior.

### Some pain points in the past


![Some pain 
points](https://user-images.githubusercontent.com/11485990/43990937-2c4087c6-9d95-11e8-8e77-8d2b0b2418b0.png)

fact1: some applications changed at the same time in different branch,like 
A,B,C.
fact2: some applications didn't change ,but deploy repeatedly,like D,E.
fact3: if a new feature need to be tested, all 5 application need to be 
deployed.
fact4: isolation by feature is not friendly to parallel development.

### Benefited from tag

![isolation by 
tag](https://user-images.githubusercontent.com/11485990/43990957-8b0508f4-9d95-11e8-8373-e522df81a227.png)

we consider the RED,YELLOW,BLUE as **tagged service** , the grey block as 
origin service or normal service.

The benefit we have is that we have reduced a lot of overhead about application 
deployment. **Only changed applications need deploy incrementally** .

### A vivid example

![A vivid 
example](https://user-images.githubusercontent.com/11485990/43990971-d7d709d4-9d95-11e8-8646-5275a8579953.png)

### Usage

#### consumer

```
RpcContext.getContext().setAttachment("request.tag","red");
```

I suggest you can use filter or SPI to set this attachment, notice that 
RpcContext is bound to Thread.

#### provider

```
@Bean
public ApplicationConfig applicationConfig() {
    ApplicationConfig applicationConfig = new ApplicationConfig();
    applicationConfig.setName("provider-book");
    // instruct tag router
    Map<String,String> parameters = new HashMap<>();
    parameters.put(Constants.ROUTER_KEY, "tag");
    applicationConfig.setParameters(parameters);
    return applicationConfig;
}
```

### Need more discussion

1. If a tag request can not find any application of the same tag,should it use 
other application of different tag (NOTICE : different tag is not the default 
application with grey block)
2. If a normal request can not find normal application,should it use any tag 
application?(in my opinion,normal request should not reach the tag 
application,also the current version).
3. A forceTag flag  can be considered to decided the behavior of downgrade. 
forceTag=true means all tag requests must strictly match the application's 
tag;forceTag=false means tag requests will prefer the application of the same 
tag,if there is no corresponding application, downgrade to other 
application,ignore the tag.
4. On the basis of 3.  what is default value of foreTag TRUE or FALSE.

more suggestions are welcome to make.

[ Full content available at: 
https://github.com/apache/incubator-dubbo/issues/2341 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to