kong.nginx package

Submodules

kong.nginx.shared module

class kong.nginx.shared.shared[source]

Bases: object

static get(k: str) Any[source]

get a key-value pair from Kong’s shared memory

Parameters:

k (str) – key for the ctx data

Returns:

the per-request context data in ngx.ctx

Return type:

Any

static set(k: str, v: str) None[source]

set a key-value pair in Kong’s shared memory

Parameters:
  • k (str) – key for the ctx data

  • v (str) – value for the ctx data

Module contents

class kong.nginx.nginx[source]

Bases: object

static get_ctx(k: str) Any[source]

get a key-value pair from Kong’s per-request context

Parameters:

k (str) – key for the ctx data

Returns:

the per-request context data in ngx.ctx

Return type:

Any

static get_statistics() table[source]

Returns various connection and request metrics exposed by Nginx, similar to those reported by the [ngx_http_stub_status_module](https://nginx.org/en/docs/http/ngx_http_stub_status_module.html#data). The following fields are included in the returned table: * connections_active - the current number of active client connections including connections_waiting. * connections_reading - the current number of connections where nginx is reading the request header. * connections_writing - the current number of connections where nginx is writing the response back to the client. * connections_waiting - the current number of idle client connections waiting for a request. * connections_accepted - the total number of accepted client connections. * connections_handled - the total number of handled connections. Same as connections_accepted unless some resource limits have been reached

(for example, the [worker_connections](https://nginx.org/en/docs/ngx_core_module.html#worker_connections) limit).

  • total_requests - the total number of client requests.

Example:

nginx_statistics = kong.nginx.get_statistics()

Returns:

Nginx connections and requests statistics

Return type:

table

static get_subsystem() str[source]
Returns:

the subsystem name

Return type:

str

static get_tls1_version_str() str[source]
Returns:

the TLSv1 version string

Return type:

str

static get_var() str[source]
Returns:

get NGINX variable value

Return type:

str

static req_start_time() number[source]

get the current request’s start timestamp

Returns:

req_start_time

Return type:

number

static set_ctx(k: str, any: str) None[source]

set a key-value pair in Kong’s per-request context

Parameters:
  • k (str) – key for the ctx data

  • any (str) – value for the ctx data

class shared

Bases: object

static get(k: str) Any

get a key-value pair from Kong’s shared memory

Parameters:

k (str) – key for the ctx data

Returns:

the per-request context data in ngx.ctx

Return type:

Any

static set(k: str, v: str) None

set a key-value pair in Kong’s shared memory

Parameters:
  • k (str) – key for the ctx data

  • v (str) – value for the ctx data