Skip to main content

Kong PDK for Python and Plugin Server

Project description

kong-python-pluginserver

PyPI version

Plugin server and PDK (Plugin Development Kit) for Python language support in Kong.

Requires Kong >= 2.3.0.

Documentation

See in Kong Docs

Install the plugin server

pip3 install kong-pdk

Usage

usage: kong-python-pluginserver [-h] [-p prefix] [-v] [--version] [--socket-name SOCKET_NAME] [--listen-queue-size LISTEN_QUEUE_SIZE]
                         [--no-lua-style] [-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 (default: /usr/local/kong/)
  -v, --verbose         turn on verbose logging (default: 1)
  --version, -version   show program's version number and exit
  --socket-name SOCKET_NAME
                        socket name to listen on (default: python_pluginserver.sock)
  --listen-queue-size LISTEN_QUEUE_SIZE
                        socket listen queue size (default: 4096)
  --no-lua-style        turn off Lua-style "data, err" return values for PDK functions and throw exception instead (default: False)
  -m, --multiprocessing
                        enable multiprocessing (default: False)
  -g, --gevent          enable gevent (default: False)
  -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

PDK API reference

The PDK (plugin developemet kit) API document can be viewed here.

Reference is generated by Sphinx under doc folder and published to the gh-pages branch. To generate updated docs, use:

git worktree add docs/build/html gh-pages
cd docs
make deps && make html

Deprecation Notice

In next major release of Kong Python PDK, return values will default to use Python style error handling instead of Lua style. The new style API can be turned on now with --no-lua-style.

# old lua-style PDK API
host, err = kong.request.get_header("host")
if err:
    pass # error handling

# new python-style PDK API
try:
    host = kong.request.get_header("host")
    # no err in return, instead they are thrown if any
except Exception as ex:
    pass # error handling

TODO

  • Tests
  • Hot reload

Unreleased

0.3.3 - 2023-02-01

0.3.2 - 2022-11-08

bug fixes

  • add version field in PluginInfo rpc (#79) 132f31d

0.3.1 - 2022-06-13

bug fixes

  • plugin closure syntax correction (#64) 920cc26
  • removing upper() to allow matching of attributes (#69) 1997a6c
  • #50: return type of get_raw_bodys should be binary string 59ab367
  • catch error from PDK methods (#53) 7f82677
  • #50: return type should support binary string fdb2c9b

0.3.0 - 2022-02-17

bug fixes

  • add option to use python style error handling to be consistent with style headers 39a75bd
  • include correct instances list in get_status 56d7ad7
  • exit immediately from kong.response.{error,exit} ba3d5fa

0.2.7 - 2021-08-04

bug fixes

  • correctly pass schema in embedded server 099a498
  • no longer normalize hyphens in socket name in embedded server to keep consistent with what Kong expects 20c01da

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

  • check correct flags existence in dedicated server (#10) b18dd45
  • set larger listen queue size (#9) a3eb340

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

0.2.1 - 2021-02-24

bug fixes

  • disable gevent in multiprocessing and make it optional 5b6fb68
  • chmod+x on examples 1f5905d

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

  • exit server if parent is dead 0ee2183
  • embed server in plugin af55deb

0.1.2 - 2020-02-21

bug fixes

0.1.1 - 2020-02-20

0.1.0 - 2020-01-03

Project details


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.33.tar.gz (42.0 kB view details)

Uploaded Source

Built Distributions

kong_pdk-0.33-py3-none-any.whl (50.4 kB view details)

Uploaded Python 3

kong_pdk-0.33-py2-none-any.whl (50.4 kB view details)

Uploaded Python 2

File details

Details for the file kong_pdk-0.33.tar.gz.

File metadata

  • Download URL: kong_pdk-0.33.tar.gz
  • Upload date:
  • Size: 42.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.9

File hashes

Hashes for kong_pdk-0.33.tar.gz
Algorithm Hash digest
SHA256 4273deda74f213ca7944731d03584e86eb0e7b22e7e759793d5e1e03115d0de1
MD5 9050ef1dfd7f57f9e0d96e9b13517c7f
BLAKE2b-256 512937b5bb57582609e49b8a83f5b83ce5ce4404be207d47af7c4fb3c2ff4c58

See more details on using hashes here.

File details

Details for the file kong_pdk-0.33-py3-none-any.whl.

File metadata

  • Download URL: kong_pdk-0.33-py3-none-any.whl
  • Upload date:
  • Size: 50.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.9

File hashes

Hashes for kong_pdk-0.33-py3-none-any.whl
Algorithm Hash digest
SHA256 2e84971775e13dc2d7c327857c26c14374b0eb60c023979c893154f37f17c493
MD5 6c6470b574618affe200e5801a29ecf9
BLAKE2b-256 c9c10f928c8ad6a686bedaf5ab1d7635db1b57bdf843884e38b83b3d936c18e2

See more details on using hashes here.

File details

Details for the file kong_pdk-0.33-py2-none-any.whl.

File metadata

  • Download URL: kong_pdk-0.33-py2-none-any.whl
  • Upload date:
  • Size: 50.4 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.9

File hashes

Hashes for kong_pdk-0.33-py2-none-any.whl
Algorithm Hash digest
SHA256 268eefae4a5d272c6db841eb05a3ef1850e17f5c4693f4ff162677e0eeacf2cc
MD5 3fdb53cedc6cbebc17119cf129ae8a7c
BLAKE2b-256 fb964becbbd00c24847549044c6029c618c2d663fdfe3eb893ddd9fd7d82344c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page