change-propagation
Version:
Listens to events from Kafka and delivers them
138 lines (134 loc) • 4.44 kB
YAML
spec:
x-sub-request-filters:
- type: default
name: http
options:
allow:
- pattern: /^https?:\/\//
forward_headers:
user-agent: true
title: The Change Propagation root
paths:
/sys/limit:
x-modules:
- path: sys/rate_limiter.js
options:
redis:
host: localhost
port: 6379
limiters:
blacklist:
interval: 604800
limit: 100
/sys/queue:
x-modules:
- path: sys/kafka.js
options:
metadata_broker_list: 127.0.0.1:9092
consume_dc: test_dc
produce_dc: test_dc
startup_delay: 0
consumer:
fetch.wait.max.ms: "1"
fetch.min.bytes: "1"
queue.buffering.max.ms: "1"
producer:
compression.codec: snappy
concurrency: 1
# Redis-mock does not support evalsha that rate limiting depend on.
disable_ratelimit: '{env(MOCK_SERVICES)}'
templates:
simple_test_rule:
topic: /^simple_test_rule$/
retry_limit: 2
retry_delay: 10
retry_on:
status:
- '50x'
- 400
ignore:
status:
- 403
- 412
match:
meta:
uri: 'https://en.wikipedia.org/wiki/SamplePage'
message: 'test'
limiters:
blacklist: '{{message.message}}'
exec:
method: post
uri: 'http://mock.com'
headers:
test_header_name: test_header_value
content-type: application/json
body:
test_field_name: test_field_value
derived_field: '{{message.message}}'
random_field: '{{message.random}}'
redirect_testing_rule:
topic: simple_test_rule
match:
meta:
uri: 'https://en.wikipedia.org/wiki/SamplePage'
message: 'redirect'
exec:
method: get
uri: 'http://mock.com/will_redirect'
kafka_producing_rule:
topic: kafka_producing_rule
exec:
method: 'post'
uri: '/sys/queue/events'
body:
- meta:
topic: '{{message.produce_to_topic}}'
uri: '{{message.meta.uri}}'
message: 'test'
triggered_by: '{{message.meta.topic}}:{{message.meta.uri}}'
- meta:
topic: '{{message.produce_to_topic}}'
uri: '{{message.meta.uri}}'
message: 'test'
triggered_by: '{{message.meta.topic}}:{{message.meta.uri}}'
sample_testing_rule:
topic: sample_test_rule
sample:
rate: 0.2
hash_template: '{{message.meta.domain}}-{{message.page_title}}'
match:
meta:
uri: 'https://en.wikipedia.org/wiki/SamplePage'
message: 'sampled'
exec:
method: get
uri: 'http://mock.com/{{message.meta.domain}}/{{message.page_title}}'
array_rule:
topics:
- simple_test_rule
- simple_test_rule2
- simple_test_rule3
exclude_topics:
- simple_test_rule3
exec:
method: post
uri: 'http://mock2.org'
body:
topic: '{{message.meta.topic}}'
num_workers: 0
logging:
name: changeprop
level: fatal
streams:
- type: stdout
metrics: # To also examine the metrics code paths, don't care that UDP goes to nowhere
type: statsd
host: localhost
port: 8125
services:
- name: changeprop
module: hyperswitch
conf:
user_agent: ChangePropTestSuite
port: 7272
spec: