Kong Go Plugin Server
Go to file
2022-04-11 21:15:44 +08:00
.gitignore
.travis.yml tests(*) new plugin name 2022-02-15 13:07:13 -03:00
CHANGELOG.md New release required for multiple-pluginserver 2020-12-07 21:27:28 -05:00
event.go
go.mod tests(*) new plugin name 2022-02-15 13:07:13 -03:00
go.sum bump go-pdk v0.6.0 2021-01-08 21:50:16 -05:00
instance.go new CLI option dump-all-plugins 2020-11-22 17:22:04 -05:00
LICENSE.txt
main.go new CLI option dump-all-plugins 2020-11-22 17:22:04 -05:00
Makefile
pluginserver.go
README.md docs stop maintenance 2022-04-11 21:15:44 +08:00
steptypes.go
test.sh tests(*) new plugin name 2022-02-15 13:07:13 -03:00

go-pluginserver

DEPRECATED

NOTE: the external go-pluginserver is deprecated, and no longer maintained. For Kong 2.8.0, while existing usage of the old style will still be supported, users are encouraged to upgrade to the new embedded server style. And it will be no longer supported since Kong 3.0.0. Check out the Docs for upgrade steps.

Pluginserver

Runs Kong plugins written in Go. Implemented as a standalone MessagePack-RPC server.

There's no explicit state associated with the client connections, so the same plugins, instances and even events could be shared with several clients, or a single client can use more than one connection from a pool. For the same reason, plugin instances and events could survive client disconnections, if the client reconnects when necessary.

Holds the running server status. Starts and stops with the server process.

RPC Methods:

  • plugin.SetPluginDir()
  • plugin.GetPluginInfo()

Plugin Instance

Holds a plugin config object, directly related to each configuration instance. The config object is defined by the plugin code, and exported fields (name starts with a caplital letter) are filled with configuration data and described in the schema. Any private field is ignored but preserved between events.

RPC Methods:

  • plugin.StartInstance()
  • plugin.InstanceStatus()
  • plugin.CloseInstance()

The StartInstance() method receives configuration data in a serialized format (currently JSON) in a binary string. If the configuration is modified externally, a new instance should be started and the old one closed.

Event

Handles a Kong event. The event instance lives during the whole callback/response cyle. Several events can share a single plugin instance concurrently, exercise care if mutating shared data.

RPC Methods:

  • plugin.HandleEvent()
  • plugin.Step()
  • plugin.StepError()
  • plugin.StepCredential()
  • plugin.StepRoute()
  • plugin.StepService()
  • plugin.StepConsumer()
  • plugin.StepMemoryStats()

To start an event, call plugin.HandleEvent() with an instance id and event name. The return data will include the event ID and either a "ret" string or callback request and parameters. If the callback response is a primitive type (number, string, simple dictionary) return it via the plugin.Step() method, including the event ID. To return an error, use plugin.StepError(). For other specific complex types, use the corresponding plugin.StepXXX() method.