Kong PDK for Python and Plugin Server
Project description
kong-python-pluginserver
Plugin server and PDK (Plugin Development Kit) for Python language support in Kong.
Requires Kong >= 2.3.0.
Install the plugin server
pip3 install kong-pdk
Usage
usage: kong-pluginserver.py [-h] [-p prefix] [-v] [--version]
[--socket-name SOCKET_NAME] [-m | -g] -d directory
[--dump-plugin-info name] [--dump-all-plugins]
Kong Python Plugin Server.
optional arguments:
-h, --help show this help message and exit
-p prefix, --kong-prefix prefix, -kong-prefix prefix
unix domain socket path to listen
-v, --verbose turn on verbose logging
--version, -version show program's version number and exit
--socket-name SOCKET_NAME
socket name to listen on
-m, --multiprocessing
enable multiprocessing
-g, --gevent enable gevent
-d directory, --plugins-directory directory, -plugins-directory directory
plugins directory
--dump-plugin-info name, -dump-plugin-info name
dump specific plugin info into stdout
--dump-all-plugins, -dump-all-plugins
dump all plugins info into stdout
Configure Kong
Add the following line into kong.conf
:
plugins=bundled,py-hello,py-image
pluginserver_names=go, py
pluginserver_py_socket=/usr/local/kong/python_pluginserver.sock
pluginserver_py_start_cmd=/usr/local/bin/kong-python-pluginserver -d /dir/to/kong-python-pdk/examples
pluginserver_py_query_cmd=/usr/local/bin/kong-python-pluginserver -d /dir/to/kong-python-pdk/examples --dump-all-plugins
For example, to test examples, clone kong-python-pdk
to /dir/to/kong-python-pdk
.
To use seperate instance for each plugin, use:
plugins=bundled,py-hello,py-image
pluginserver_names=go, py-hello, py-image
pluginserver_py_hello_socket=/usr/local/kong/py_hello.sock
pluginserver_py_hello_start_cmd=/dir/to/kong-python-pdk/examples/py-hello.py
pluginserver_py_hello_query_cmd=/dir/to/kong-python-pdk/examples/py-hello.py -d
pluginserver_py_image_socket=/usr/local/kong/py_image.sock
pluginserver_py_image_start_cmd=/dir/to/kong-python-pdk/examples/py-image.py
pluginserver_py_image_query_cmd=/dir/to/kong-python-pdk/examples/py-image.py -d
Enable the plugin
Same step as it's a Lua plugin.
Notes
- All PDK API supported by Go Plugin Server is supported.
- If your plugins are CPU intensive, consider using multiprocessing mode (
-m
flag) or run the plugin instance in a seperate process (examples/py-hello.py as an example) to distribute workloads to multicore. - If your plugins are I/O intensive, considering using gevent mode (
-g
flag) and use gevent libraries in the plugin.
TODO
- Tests
- Hot reload
Unreleased
0.2.7 - 2021-08-04
0.2.6 - 2021-07-19
bug fixes
- listener to use msgpack.Unpacker iterrator bed56c4
0.2.5 - 2021-06-24
bug fixes
0.2.4 - 2021-06-17
bug fixes
0.2.3 - 2021-05-13
bug fixes
- display defaults on cli and print PluginServerException to warning 13991ec
- skip running cleanup timer e10c098
- standarlize error on instance not found 0dfc94f
features
0.2.2 - 2021-03-29
bug fixes
- correct license in setup.py (#3) b257c98
- threading mode pipe and styles 6f73ac7
- enable plugin server without gevent mode a29c4d7
features
- add typed interfaces f98e44d
0.2.1 - 2021-02-24
bug fixes
features
0.2.0 - 2021-02-22
bug fixes
- sync with Kong 2.3 update d42de7e
code refactoring
- rename kong_pluginserver to kong_pdk e802627
features
0.1.2 - 2020-02-21
bug fixes
- python2 compatibility 0e4cf1c
0.1.1 - 2020-02-20
0.1.0 - 2020-01-03
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
kong_pdk-0.27.tar.gz
(27.1 kB
view details)
Built Distributions
kong_pdk-0.27-py3-none-any.whl
(34.2 kB
view details)
kong_pdk-0.27-py2-none-any.whl
(34.2 kB
view details)
File details
Details for the file kong_pdk-0.27.tar.gz
.
File metadata
- Download URL: kong_pdk-0.27.tar.gz
- Upload date:
- Size: 27.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eba1b0d82fab007136df9b814346fda96034a172bc35371f69d16496f9c0f2d5 |
|
MD5 | 260e31f4cf8b230cb9f02cc35e4c7196 |
|
BLAKE2b-256 | a264eda1915b5a01f125e27ae6c6f03cdf8e255f0b99b35f504f9736659f10dd |
File details
Details for the file kong_pdk-0.27-py3-none-any.whl
.
File metadata
- Download URL: kong_pdk-0.27-py3-none-any.whl
- Upload date:
- Size: 34.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 081f1846404cdbaae85c6efdd0fb02f65e06981cd1d8c442b152d8eca97aca67 |
|
MD5 | 7f983e3246b034d6e87ee0d9ffddf75d |
|
BLAKE2b-256 | b54e2a6a205107bc8bdd73a7780c9ce030093efc8c0580c3d8ff07f16a01f130 |
File details
Details for the file kong_pdk-0.27-py2-none-any.whl
.
File metadata
- Download URL: kong_pdk-0.27-py2-none-any.whl
- Upload date:
- Size: 34.2 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f443c35668c668d7d5a6302751307ae1ad7e9d614a21389926eb9de694eb01da |
|
MD5 | 802ecbbfd9787a5f34d7e6bf1bba4f4c |
|
BLAKE2b-256 | f6ecbf91d26a90104c7c466b64376e91c0e40f23c9b5fd89acedfee566f3145e |