Uploaded image for project: 'Apache ServiceComb'
  1. Apache ServiceComb
  2. SCB-1929

provide new mechanism: Filter

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • java-chassis-3.0.0
    • Java-Chassis
    • None

    Description

      currently, we have extensions:

      1. HttpClientFilter
      2. HttpServerFilter
      3. Handler
      4. ProducerInvokeExtension

      and we hard code to invoke all the extensions:

      1. consumer:
        1. invoke all handlers
        2. invoke all HttpClientFilters
      2. producer:
        1. schedule to operation related executor
        2. invoke all HttpServerFilters
        3. invoke all handlers

      PROBLEMS:

      1. all these extensions are about invocation, just have different prototype
      2. for consumer
        1. when a sync invocation failed, and want to retry, retry schedule is conflict to sync mechanism
      3. for producer
        1. qps-limiter should invoke before schedule, currently we hard code it
        2. if want to write reactive extension before schedule, to not care for controller method is sync or async, currently can not do it
        3. 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
      4. 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

      1. 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);
        }
        
      2. 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
        
        1. customize full flow of invocation
        2. microservice scope chain
        3. schema or operation scope chain, if have requirements in the future
        4. invoke exception converter when throwing a exception for all filter

      COMPATIBLE:

      1. wrap old HttpClientFilters to a Filter
      2. wrap old HttpServerFilters to a Filter
      3. wrap old consumer handlers to a Filter
      4. wrap old producer handlers to a Filter
      5. pre-define old filter chains, and default to old chains

      Attachments

        Issue Links

          There are no Sub-Tasks for this issue.

          Activity

            People

              liubao68 liubao
              wujimin Jimin Wu
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: