Skip to content

Instantly share code, notes, and snippets.

@arifsetiawan
Forked from dio/README.md
Last active October 16, 2019 23:00
Show Gist options
  • Save arifsetiawan/f98cd5cefc6a603407d1089a77df4a29 to your computer and use it in GitHub Desktop.
Save arifsetiawan/f98cd5cefc6a603407d1089a77df4a29 to your computer and use it in GitHub Desktop.
$ yarn
$ # or npm install
$ node dump.js
$ # from another tab
$ envoy -c envoy.yaml
$ # from another tab
$ curl localhost:10000
const Server = require('http').Server;
const rawBody = require('raw-body');
const sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, milliseconds))
}
const server = new Server(async (req, res) => {
console.log("==request==");
console.log("time", new Date());
console.log("url",req.url);
console.log("headers",req.headers);
sleep(30000).then(() => {
console.log("==response==");
console.log("time", new Date());
res.statusCode = 200;
res.end('ok');
})
});
server.listen(process.env.PORT || 8000);
admin:
access_log_path: /tmp/admin_access.log
address:
socket_address:
protocol: TCP
address: 127.0.0.1
port_value: 9901
static_resources:
listeners:
- name: listener_0
address:
socket_address:
protocol: TCP
address: 0.0.0.0
port_value: 10000
filter_chains:
- filters:
- name: envoy.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains: ["*"]
routes:
- match:
prefix: "/"
route:
timeout: 20s
retry_policy:
retry_on: 5xx
num_retries: 5
per_try_timeout: 5s
retry_host_predicate:
- name: envoy.retry_host_predicates.previous_hosts
- name: envoy.retry_host_predicates.previous_hosts
host_selection_retry_max_attempts: '5'
retriable_status_codes:
- 503
max_grpc_timeout: 20s
cluster: service_google
http_filters:
- name: envoy.router
clusters:
- name: service_google
connect_timeout: 0.25s
type: LOGICAL_DNS
# Comment out the following line to test on v6 networks
dns_lookup_family: V4_ONLY
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: service_google
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: localhost
port_value: 8000
{
"name": "hello",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"raw-body": "^2.4.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment