
---
regexp_section:
  matcher:
    match_and:
      - match_fsm:
          host: 'l7test\\.yandex\\.(.+)'
      - match_fsm:
          uri: '/(weather|pogoda|hava)-prestable(.+)?' 
  modules:
    - rps_limiter_macro: 
        record_name: weather_front
        use_sd_backends: true
    - remote_log:
        remote_log_storage:
          modules:
            - balancer2:
                rr: {}
                attempts: 2
                attempts_rate_limiter:
                  limit: 0.2
                generated_proxy_backends:
                    proxy_options:
                      backend_timeout: 5s
                      keepalive_count: 0
                    include_backends:
                      type: BY_ID
                      ids: [remote_logger_iva, remote_logger_sas]
    - report:
        ranges: default
        uuid: prestable
    - regexp:
        sections:
          # Запросы за картой из натива
          pres_native_nowcast:
            matcher:
              match_fsm:
                cgi: '.*(nowcast=[1,2]).*'
            modules:
              - report:
                  ranges: default
                  uuid: pres_native_nowcast
              - shared: {uuid: pres_without_auto_pumpkin}

          # Запросы за карточными манифестами
          manifest:
            matcher:
              match_fsm:
                  uri: '/(weather|pogoda|hava)-prestable/front/maps/manifest(.*)'
            modules:
              - report:
                  ranges: default
                  uuid: old_manifest
              - errordocument:
                  status: 404
                  content: Not Found

          # Запросы во фронтбэк по урлу /front. Не должны тыквиться
          pres_frontback:
            matcher:
              match_fsm:
                uri: '/(weather|pogoda|hava)-prestable/front(/.*)?'
            modules:
              - report:
                  ranges: default
                  uuid: pres_frontback
              - shared: {uuid: pres_without_auto_pumpkin}
              - balancer2:
                  active_policy:
                    unique_policy: {}
                  attempts: 1
                  connection_attempts: 3
                  dynamic:
                    max_pessimized_share: 0.2
                  generated_proxy_backends:
                    proxy_options:
                      connect_timeout: 100ms
                      backend_timeout: 7s
                      keepalive_count: 1
                      fail_on_5xx: false
                    include_backends:
                      type: BY_ID
                      ids: [weather-prestable-frontend]
                  on_error:
                    modules:
                      - errordocument:
                          status: 503
                          content: 'Service unavailable'

          # Запросы за json-ом для spa. Должны тыквиться
          pres_tap:
            matcher:
                match_fsm:
                  cgi: '.*turboapp=1.*'
            modules:
              - report:
                  ranges: default
                  uuid: pres_tap
              - shared: {uuid: pres_tap}
              - balancer2:
                  attempts: 1
                  rr:
                    weights_file: ./controls/traffic_control.weights
                  backends:
                    - name: datasource_runtime
                      weight: 1
                      modules:
                        - balancer2:
                            active_policy:
                              unique_policy: {}
                            attempts: 1
                            dynamic:
                              max_pessimized_share: 0.2
                            generated_proxy_backends:
                              proxy_options:
                                connect_timeout: 100ms
                                backend_timeout: 7s
                                keepalive_count: 1
                                fail_on_5xx: true
                                status_code_blacklist: [4xx, 5xx]
                                status_code_blacklist_exceptions: ["403", "404", "429"]
                              include_backends:
                                type: BY_ID
                                ids: [weather-prestable-frontend]
                            on_error:
                              modules:
                                - shared: {uuid: tap_pumpkin}
                    - name: datasource_pumpkin
                      weight: -1
                      modules:
                        - shared: {uuid: tap_pumpkin}

          # Пользовательские запросы за криптованным html. Проверяем, что есть кука антиадблока и не выставлен заголовок x-aab-proxy(он выставляется на стороне антиадблока). Должно тыквиться
          pres_cryprox_cookie:
            matcher:
              match_and:
                - match_or:
                  - match_fsm: {cookie: 'bltsr=1', surround: True}
                  - match_fsm: {cookie: 'qgZTpupNMGJBM=1', surround: True}
                  - match_fsm: {cookie: 'mcBaGDt=1', surround: True}
                  - match_fsm: {cookie: 'BgeeyNoBJuyII=1', surround: True}
                  - match_fsm: {cookie: 'orrXTfJaS=1', surround: True}
                  - match_fsm: {cookie: 'FgkKdCjPqoMFm=1', surround: True}
                  - match_fsm: {cookie: 'EIXtkCTlX=1', surround: True}
                  - match_fsm: {cookie: 'JPIqApiY=1', surround: True}
                  - match_fsm: {cookie: 'KIykI=1', surround: True}
                  - match_fsm: {cookie: 'HgGedof=1', surround: True}
                  - match_fsm: {cookie: 'ancQTZw=1', surround: True}
                  - match_fsm: {cookie: 'involved=1', surround: True}
                  - match_fsm: {cookie: 'instruction=1', surround: True}
                  - match_fsm: {cookie: 'engineering=1', surround: True}
                  - match_fsm: {cookie: 'telecommunications=1', surround: True}
                  - match_fsm: {cookie: 'discussion=1', surround: True}
                  - match_fsm: {cookie: 'computer=1', surround: True}
                  - match_fsm: {cookie: 'substantial=1', surround: True}
                  - match_fsm: {cookie: 'specific=1', surround: True}
                  - match_fsm: {cookie: 'engineer=1', surround: True}
                  - match_fsm: {cookie: 'adequate=1', surround: True}
                  - match_fsm: {cookie: 'Silver=1', surround: True}
                  - match_fsm: {cookie: 'Mercury=1', surround: True}
                  - match_fsm: {cookie: 'Bismuth=1', surround: True}
                  - match_fsm: {cookie: 'Silicon=1', surround: True}
                  - match_fsm: {cookie: 'Tennessine=1', surround: True}
                  - match_fsm: {cookie: 'Zinc=1', surround: True}
                  - match_fsm: {cookie: 'Sulfur=1', surround: True}
                  - match_fsm: {cookie: 'Nickel=1', surround: True}
                  - match_fsm: {cookie: 'Radon=1', surround: True}
                  - match_fsm: {cookie: 'Manganese=1', surround: True}
                  - match_fsm: {cookie: 'LBCBNrZSu=1', surround: True}
                  - match_fsm: {cookie: 'VTouhmwR=1', surround: True}
                  - match_fsm: {cookie: 'TbwgcPzRMgzVo=1', surround: True}
                  - match_fsm: {cookie: 'liPkbtFdIkYqc=1', surround: True}
                  - match_fsm: {cookie: 'HOhdORSx=1', surround: True}
                  - match_fsm: {cookie: 'EMCzniGaQ=1', surround: True}
                  - match_fsm: {cookie: 'PIwsfZeu=1', surround: True}
                  - match_fsm: {cookie: 'FxuGQqNNo=1', surround: True}
                  - match_fsm: {cookie: 'sMLIIeQQeFnYt=1', surround: True}
                  - match_fsm: {cookie: 'pClnKCSBXcHUp=1', surround: True}
                  - match_fsm: {cookie: 'tCTmkfFoXn=1', surround: True}
                  - match_fsm: {cookie: 'zmFQeXtI=1', surround: True}
                  - match_fsm: {cookie: 'ScSvCIlBC=1', surround: True}
                  - match_fsm: {cookie: 'kNAcVGYFWhx=1', surround: True}
                  - match_fsm: {cookie: 'jsOmqPGh=1', surround: True}
                  - match_fsm: {cookie: 'OqYspIFcUpLY=1', surround: True}
                  - match_fsm: {cookie: 'XcfPaDInQpzKj=1', surround: True}
                  - match_fsm: {cookie: 'hcxWnzbUzfz=1', surround: True}
                  - match_fsm: {cookie: 'MGphYZof=1', surround: True}
                  - match_fsm: {cookie: 'NBgfDVFir=1', surround: True}
                - match_not:
                    match_fsm:
                      uri: '/(weather|pogoda|hava)-prestable[a-z0-9-]*/(front|ping|widgets|banners|turbo)'
                - match_not:
                    match_fsm:
                      header: {name: x-aab-proxy, value: '1'}
                - match_not:
                    match_fsm:
                      uri: '/(weather|pogoda|hava)-prestable[a-z0-9-]*/_cry(.*)'
            modules:
              - report: {uuid: pres_going_to_cryproxy, ranges: default}
              - shared: {uuid: cry_with_auto_pumpkin}

          # Запросы по криптованным урлам и отправка статистики антиадблока. Не должно тыквиться
          pres_cryprox_cry:
            matcher:
              match_and:
                - match_fsm:
                    uri: '/(weather|pogoda|hava)-prestable[a-z0-9-]*/_cry(.*)'
                - match_not:
                    match_fsm:
                      uri: '/(weather|pogoda|hava)-prestable[a-z0-9-]*/(front|ping|widgets|banners|turbo)'
            modules:
              - report: {uuid: pres_going_to_cryproxy, ranges: default}
              - shared: {uuid: cry_without_auto_pumpkin}

          # Запросы из антиадблока за нашим html-ем. Не должно тыквиться, так как едет вёрстка. Если будет пятисотить, то перехватится выше в секции cryprox_cookie
          pres_request_from_cryproxy:
            matcher:
              match_and:
                - match_fsm:
                    header: {name: x-aab-proxy, value: '1'}
            modules:
              - report: {uuid: pres_request_from_cryproxy, ranges: default}
              - shared: {uuid: pres_without_auto_pumpkin}

          # Всё остальное, что не сматчилось
          pres_default:
            matcher: {}
            modules:
              - report: { ranges: default, uuid: pres_default }
              - shared: {uuid: pres_with_auto_pumpkin}
              - balancer2:
                  attempts: 1
                  rr:
                    weights_file: ./controls/traffic_control.weights
                  backends:
                    - name: datasource_runtime
                      weight: 1
                      modules:
                        # Не через shared потому что нужно, чтобы не было on_error и всплыло до автотыквы
                        - headers:
                            create:
                              DidNotProxy: '1'
                        - balancer2:
                            active_policy:
                              unique_policy: {}
                            attempts: 1
                            connection_attempts: 3
                            dynamic:
                              max_pessimized_share: 0.2
                            generated_proxy_backends:
                              proxy_options:
                                connect_timeout: 100ms
                                backend_timeout: 7s
                                keepalive_count: 1
                                fail_on_5xx: true
                                status_code_blacklist: [4xx, 5xx]
                                status_code_blacklist_exceptions: ["403", "404", "429"]
                              include_backends:
                                type: BY_ID
                                ids: [weather-prestable-frontend]
                    - name: datasource_pumpkin
                      weight: -1
                      modules:
                        - shared: {uuid: html_pumpkin}
                  on_error:
                    modules:
                      - shared: {uuid: html_pumpkin}
