Details
-
New Feature
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
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:
public @interface FilterMeta { String name(); /** * * @return can be used for the specific invocation type */ InvocationType[] invocationType() default {CONSUMER, PRODUCER}; /** * * @return true to use same instance for each filter chain */ boolean shareable() default true; } public interface Filter { CompletableFuture<Response> onFilter(Invocation invocation, FilterNode nextNode); }
- configuration
servicecomb: filter-chains: enabled: true transport-filters: #default-consumer-transport: # rest: rest-client-codec # highway: highway-client-codec default-producer-tranport: rest: rest-server-codec highway: highway-server-codec consumer: default: simple-load-balance #default: simple-load-balance, default-consumer-transport, transport-client # samples for customize microservice filter chain #policies: # ms-1: retry, load-balance, transport-client, ms-1-consumer-transport producer: default: default-producer-tranport, schedule, producer-operation # samples for customize microservice filter chain #policies: # ms-1: qps-limiter, ms-1-producer-transport, schedule, producer-operation
- customize full flow of invocation
- microservice scope chain
- schema or operation scope chain, if have requirements in the future
- invoke exception converter when throwing a exception for all filter
COMPATIBLE:
- wrap old HttpClientFilters to a Filter
- wrap old HttpServerFilters to a Filter
- wrap old consumer handlers to a Filter
- wrap old producer handlers to a Filter
- pre-define old filter chains, and default to old chains
Attachments
Issue Links
- Blocked
-
SCB-1938 OperationConfig can get in pool timeout by transport name
- Resolved
-
SCB-1946 add new exception converter for all filters, not only the last one
- Resolved
-
SCB-1947 define Filter and filter chain
- Resolved
-
SCB-1948 cache invocation.producerArguments, avoid build one more time for validator
- Resolved
-
SCB-1951 enhance HttpTransportContext
- Resolved
-
SCB-1952 enhance HighwayTransportContext
- Resolved
-
SCB-1955 create unify producer invocation flow
- Resolved
-
SCB-1959 add rest invocation creator
- Resolved
-
SCB-1961 add rest server codec filter
- Resolved
-
SCB-1962 add highway server codec filter
- Resolved
-
SCB-1965 add zipkin filter
- Resolved
-
SCB-1966 print filter chain information after bootup
- Resolved
-
SCB-1967 add simple load balance
- Resolved
-
SCB-1968 add producer operation filter
- Resolved
-
SCB-1979 load filter chains
- Resolved
-
SCB-1980 add TransportFilters to select chain by transport in runtime
- Resolved
-
SCB-1981 add filter chain to SCBEngine
- Resolved
-
SCB-1982 add validator filter
- Resolved
-
SCB-1985 allow producer invocation process by filter chain
- Resolved
-
SCB-1987 adjust test code for filter chain mode
- Resolved
-
SCB-1992 tiny improve about InvocationException
- Resolved
-
SCB-2029 tiny improve to make extend filter features easier
- Resolved
-
SCB-2033 inject spring bean to filter instance automatically
- Resolved
-
SCB-2034 move create validator to init to use injected spring bean
- Resolved
-
SCB-2037 utils for get CompletableFuture result in sync mode
- Resolved
-
SCB-2141 add RestClientTransportContext
- Resolved
-
SCB-2142 add RestClientEncoder
- Resolved
-
SCB-2146 add RestClientDecoder
- Resolved
-
SCB-2147 add RestClientCodecFilter
- Resolved
-
SCB-2148 add RestClientSender
- Resolved
-
SCB-2149 add RestClientSenderFilter
- Resolved
-
SCB-2150 allowed modify host before create HttpClientRequest
- Resolved
-
SCB-2152 allow pojo invoker process by filter chain
- Resolved
-
SCB-2156 add HighwayClientFilter
- Resolved
-
SCB-2158 optimize exception log
- Resolved
-
SCB-2159 add TimeoutExceptionConverter
- Resolved
-
SCB-2169 optimize filter declare and chain config
- Resolved
-
SCB-2170 add configuration to control log invocation exception stack trace
- Resolved
-
SCB-2218 allow edge invocation process by filter
- Resolved
-
SCB-2251 make exception processor extendable
- Resolved