diff options
author | Chris <ccbrown112@gmail.com> | 2017-09-11 10:02:02 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-11 10:02:02 -0500 |
commit | 402491b7e52c4d836c1274976cdb387852cfd17b (patch) | |
tree | e8adcbdf0af5370f8af11e3fc1021a328c971a5d /plugin/rpcplugin/hooks.go | |
parent | a69bed712d53e9a7984915fffffc8a2fd1647a7a (diff) | |
download | chat-402491b7e52c4d836c1274976cdb387852cfd17b.tar.gz chat-402491b7e52c4d836c1274976cdb387852cfd17b.tar.bz2 chat-402491b7e52c4d836c1274976cdb387852cfd17b.zip |
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
Diffstat (limited to 'plugin/rpcplugin/hooks.go')
-rw-r--r-- | plugin/rpcplugin/hooks.go | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/plugin/rpcplugin/hooks.go b/plugin/rpcplugin/hooks.go index 68bce41eb..18e4a6672 100644 --- a/plugin/rpcplugin/hooks.go +++ b/plugin/rpcplugin/hooks.go @@ -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 } |