[ https://issues.apache.org/jira/browse/SCB-1929?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jimin Wu updated SCB-1929: -------------------------- Description: currently, we have extensions: # HttpClientFilter # HttpServerFilter # Handler # ProducerInvokeExtension and we hard code to invoke all the extensions: # consumer: ## invoke all handlers ## invoke all HttpClientFilters # producer: ## schedule to operation related executor ## invoke all HttpServerFilters ## invoke all handlers PROBLEMS: # all these extensions are about invocation, just have different prototype # for consumer ## when a sync invocation failed, and want to retry, retry schedule is conflict to sync mechanism # for producer ## qps-limiter should invoke before schedule, currently we hard code it ## if want to write reactive extension before schedule, to not care for controller method is sync or async, currently can not do it ## if executor is a real thread pool, and a reactive extension after schedule will break thread schedule plan, that maybe will cause block event loop # exception convert only avaiable for controller method invoke, but all extensions exception need convert too SOLUTION: provide new mechanism: Filter, to unify all the extensions, and change main invocation process flow from hard code to by configuration # prototype: {code:java} public @interface FilterMeta { String name(); /** * * @return null for all transport */ String transport(); /** * * @return true to use same instance for each filter chain */ boolean shareable() default true; } public interface Filter { CompletableFuture<Response> onFilter(Invocation invocation, FilterNode nextNode); } {code} # configuration {code:java} servicecomb: filter-chains: defines: consumer-v1: consumer-handlers, http-client-filters producer-v1: schedule, http-server-filters, producer-handlers consumer-v2: simple-load-balance producer-v2: schedule default-consumer: $consumer-v2 default-producer: $producer-v2 consumers: ms-1: simple-retry, load-balance producers: ms-2: qps-limiter, $producer-v2 {code} ## free to pre-define multiple chains ## reference pre-define chain, and combine to new chain ## microservice scope chain ## schema or operation scope chain, if have requirements in the future # invoke exception converter when throwing a exception for all filter > provide new mechanism: Filter > ----------------------------- > > Key: SCB-1929 > URL: https://issues.apache.org/jira/browse/SCB-1929 > Project: Apache ServiceComb > Issue Type: New Feature > Components: Java-Chassis > Reporter: Jimin Wu > Assignee: Jimin Wu > Priority: Major > Fix For: java-chassis-2.1.0 > > > currently, we have extensions: > # HttpClientFilter > # HttpServerFilter > # Handler > # ProducerInvokeExtension > and we hard code to invoke all the extensions: > # consumer: > ## invoke all handlers > ## invoke all HttpClientFilters > # producer: > ## schedule to operation related executor > ## invoke all HttpServerFilters > ## invoke all handlers > > PROBLEMS: > # all these extensions are about invocation, just have different prototype > # for consumer > ## when a sync invocation failed, and want to retry, retry schedule is > conflict to sync mechanism > # for producer > ## qps-limiter should invoke before schedule, currently we hard code it > ## if want to write reactive extension before schedule, to not care for > controller method is sync or async, currently can not do it > ## if executor is a real thread pool, and a reactive extension after > schedule will break thread schedule plan, that maybe will cause block event > loop > # exception convert only avaiable for controller method invoke, but all > extensions exception need convert too > > SOLUTION: > provide new mechanism: Filter, to unify all the extensions, and change main > invocation process flow from hard code to by configuration > # prototype: > {code:java} > public @interface FilterMeta { > String name(); > /** > * > * @return null for all transport > */ > String transport(); > /** > * > * @return true to use same instance for each filter chain > */ > boolean shareable() default true; > } > public interface Filter { > CompletableFuture<Response> onFilter(Invocation invocation, FilterNode > nextNode); > } > {code} > # configuration > {code:java} > servicecomb: > filter-chains: > defines: > consumer-v1: consumer-handlers, http-client-filters > producer-v1: schedule, http-server-filters, producer-handlers > consumer-v2: simple-load-balance > producer-v2: schedule > default-consumer: $consumer-v2 > default-producer: $producer-v2 > consumers: > ms-1: simple-retry, load-balance > producers: > ms-2: qps-limiter, $producer-v2 > {code} > ## free to pre-define multiple chains > ## reference pre-define chain, and combine to new chain > ## microservice scope chain > ## schema or operation scope chain, if have requirements in the future > # invoke exception converter when throwing a exception for all filter > > -- This message was sent by Atlassian Jira (v8.3.4#803005)