Git Product home page Git Product logo

kong-plugin-random-latency's Introduction

kong-plugin-random-latency

A Kong plugin which adds a random latency to request in order to simulate bad networks

configuration parameters

FORM PARAMETER DEFAULT DESCRIPTION
config.minimum_latency_msec 0 This parameter describes the minimum latency (msec) to be added
config.maximum_latency_msec 1000 This parameter describes the maximum latency (msec) to be added
config.request_percentage 50 Percentage of requests which shall get the latency added
config.add_header true If set to true a header X-Kong-Random-Latency will be added with either the value of the added latency or none if random generator has chosen not to add a latency (see also config.request_percentage)

Example

> http :8001/services/httpbin/plugins name=random-latency 

HTTP/1.1 201 Created
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Type: application/json; charset=utf-8
Date: Thu, 04 Apr 2019 15:18:38 GMT
Server: kong/0.13.1
Transfer-Encoding: chunked

{
    "config": {
        "add_header": true,
        "maximum_latency_msec": 1000,
        "minimum_latency_msec": 0,
        "request_percentage": 50
    },
    "created_at": 1554391119000,
    "enabled": true,
    "id": "2dac1e11-6ec5-4609-ac2a-0591804ca785",
    "name": "random-latency",
    "service_id": "3a0c40f8-7c8d-4441-b0b3-de9836c4e841"
}

Response if random generator has decided to add latency:

> http :8000/latency

HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Encoding: gzip
Content-Length: 241
Content-Type: application/json
Date: Thu, 04 Apr 2019 15:21:52 GMT
Server: nginx
Via: kong/0.13.1
X-Kong-Proxy-Latency: 90
X-Kong-Random-Latency: 89
X-Kong-Upstream-Latency: 227

(BODY OF RESPONSE)

Response if random generator decided not to add latency (see "none" in header)

> http :8000/latency

HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Encoding: gzip
Content-Length: 241
Content-Type: application/json
Date: Thu, 04 Apr 2019 15:23:53 GMT
Server: nginx
Via: kong/0.13.1
X-Kong-Proxy-Latency: 1
X-Kong-Random-Latency: none
X-Kong-Upstream-Latency: 213

(BODY OF RESPONSE)

kong-plugin-random-latency's People

Contributors

svenwal avatar tieske avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.