mirror of
https://github.com/Kong/go-pluginserver.git
synced 2025-10-05 16:17:01 +08:00

* it runs... something * use strings for dict keys * small cleanups / better locking * add StepXXX RPC methods to express non-primitive PDK return types * remove commented code * define recognizable error type * config schema as a structure, not a string that happens to be decodable * changed Kong capitalization because of Go * reread plugin if modified on disk * docs about event cycle and callback return types * The standard package can't reload Plugins * add status report, including some timekeeping * expire instances after 60sec idle * a bit of logging * send PID on status and on connection (as unrequested notification)
86 lines
1.6 KiB
Go
86 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/Kong/go-pdk/client"
|
|
"github.com/Kong/go-pdk/entities"
|
|
"github.com/Kong/go-pdk/node"
|
|
)
|
|
|
|
type Error string
|
|
|
|
func (e Error) Error() string {
|
|
return string(e)
|
|
}
|
|
|
|
type StepErrorData struct {
|
|
EventId int
|
|
Data Error
|
|
}
|
|
|
|
func (s *PluginServer) StepError(in StepErrorData, out *StepData) error {
|
|
return s.Step(StepData{
|
|
EventId: in.EventId,
|
|
Data: in.Data,
|
|
}, out)
|
|
}
|
|
|
|
type StepCredentialData struct {
|
|
EventId int
|
|
Data client.AuthenticatedCredential
|
|
}
|
|
|
|
func (s *PluginServer) StepCredential(in StepCredentialData, out *StepData) error {
|
|
return s.Step(StepData{
|
|
EventId: in.EventId,
|
|
Data: in.Data,
|
|
}, out)
|
|
}
|
|
|
|
type StepRouteData struct {
|
|
EventId int
|
|
Data entities.Route
|
|
}
|
|
|
|
func (s *PluginServer) StepRoute(in StepRouteData, out *StepData) error {
|
|
return s.Step(StepData{
|
|
EventId: in.EventId,
|
|
Data: in.Data,
|
|
}, out)
|
|
}
|
|
|
|
type StepServiceData struct {
|
|
EventId int
|
|
Data entities.Service
|
|
}
|
|
|
|
func (s *PluginServer) StepService(in StepServiceData, out *StepData) error {
|
|
return s.Step(StepData{
|
|
EventId: in.EventId,
|
|
Data: in.Data,
|
|
}, out)
|
|
}
|
|
|
|
type StepConsumerData struct {
|
|
EventId int
|
|
Data entities.Consumer
|
|
}
|
|
|
|
func (s *PluginServer) StepConsumer(in StepConsumerData, out *StepData) error {
|
|
return s.Step(StepData{
|
|
EventId: in.EventId,
|
|
Data: in.Data,
|
|
}, out)
|
|
}
|
|
|
|
type StepMemoryStatsData struct {
|
|
EventId int
|
|
Data node.MemoryStats
|
|
}
|
|
|
|
func (s *PluginServer) StepMemoryStats(in StepMemoryStatsData, out *StepData) error {
|
|
return s.Step(StepData{
|
|
EventId: in.EventId,
|
|
Data: in.Data,
|
|
}, out)
|
|
}
|