PLT-7407: Back-end plugins (#7409)
* tie back-end plugins together * fix comment typo * add tests and a bit of polish * tests and polish * add test, don't let backend executable paths escape the plugin directory
Этот коммит содержится в:
@@ -86,6 +86,15 @@ func (h *LocalHooks) OnDeactivate(args, reply *struct{}) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (h *LocalHooks) OnConfigurationChange(args, reply *struct{}) error {
|
||||
if hook, ok := h.hooks.(interface {
|
||||
OnConfigurationChange() error
|
||||
}); ok {
|
||||
return hook.OnConfigurationChange()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ServeHTTPArgs struct {
|
||||
ResponseWriterStream int64
|
||||
Request *http.Request
|
||||
@@ -122,11 +131,14 @@ func ServeHooks(hooks interface{}, conn io.ReadWriteCloser, muxer *Muxer) {
|
||||
server.ServeConn(conn)
|
||||
}
|
||||
|
||||
// These assignments are part of the wire protocol. You can add more, but should not change existing
|
||||
// assignments.
|
||||
const (
|
||||
remoteOnActivate = iota
|
||||
remoteOnDeactivate
|
||||
remoteServeHTTP
|
||||
maxRemoteHookCount
|
||||
remoteOnActivate = 0
|
||||
remoteOnDeactivate = 1
|
||||
remoteServeHTTP = 2
|
||||
remoteOnConfigurationChange = 3
|
||||
maxRemoteHookCount = iota
|
||||
)
|
||||
|
||||
type RemoteHooks struct {
|
||||
@@ -164,6 +176,13 @@ func (h *RemoteHooks) OnDeactivate() error {
|
||||
return h.client.Call("LocalHooks.OnDeactivate", struct{}{}, nil)
|
||||
}
|
||||
|
||||
func (h *RemoteHooks) OnConfigurationChange() error {
|
||||
if !h.implemented[remoteOnConfigurationChange] {
|
||||
return nil
|
||||
}
|
||||
return h.client.Call("LocalHooks.OnConfigurationChange", struct{}{}, nil)
|
||||
}
|
||||
|
||||
func (h *RemoteHooks) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if !h.implemented[remoteServeHTTP] {
|
||||
http.NotFound(w, r)
|
||||
@@ -227,6 +246,8 @@ func ConnectHooks(conn io.ReadWriteCloser, muxer *Muxer) (*RemoteHooks, error) {
|
||||
remote.implemented[remoteOnActivate] = true
|
||||
case "OnDeactivate":
|
||||
remote.implemented[remoteOnDeactivate] = true
|
||||
case "OnConfigurationChange":
|
||||
remote.implemented[remoteOnConfigurationChange] = true
|
||||
case "ServeHTTP":
|
||||
remote.implemented[remoteServeHTTP] = true
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user