diff options
author | Jesse Hallam <jesse.hallam@gmail.com> | 2018-10-03 13:13:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-03 13:13:19 -0400 |
commit | 580b546862860ca389305d0d4614471095ec67fe (patch) | |
tree | 0af3d83f4c5a44f5c7b4d9379238afb7c1573330 /plugin/client_rpc.go | |
parent | b6835ab984aece679cb0d6bea548d3f2ed1c9af2 (diff) | |
download | chat-580b546862860ca389305d0d4614471095ec67fe.tar.gz chat-580b546862860ca389305d0d4614471095ec67fe.tar.bz2 chat-580b546862860ca389305d0d4614471095ec67fe.zip |
MM-12193: remove auto unmarshalling (#9519)
* MM-12193: remove auto configuration unmarshalling
Since plugin hook events are called concurrently, there's no way for the plugin framework to coordinate safe access to the automatically unmarshalled configuration fields. Remove this functionality, and update documentation to illustrate a safe way to do this.
* better Fprint example
* fix unit tests
* log when OnConfigurationChange fails through OnActivate
* clarify lifecycle when OnConfigurationChange returns an error
* call SetAPI even if OnConfigurationChange not implemented
Diffstat (limited to 'plugin/client_rpc.go')
-rw-r--r-- | plugin/client_rpc.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/plugin/client_rpc.go b/plugin/client_rpc.go index 72bd41f68..2e85466d7 100644 --- a/plugin/client_rpc.go +++ b/plugin/client_rpc.go @@ -195,11 +195,16 @@ func (s *hooksRPCServer) OnActivate(args *Z_OnActivateArgs, returns *Z_OnActivat if mmplugin, ok := s.impl.(interface { SetAPI(api API) - OnConfigurationChange() error - }); !ok { - } else { + }); ok { mmplugin.SetAPI(s.apiRPCClient) - mmplugin.OnConfigurationChange() + } + + if mmplugin, ok := s.impl.(interface { + OnConfigurationChange() error + }); ok { + if err := mmplugin.OnConfigurationChange(); err != nil { + fmt.Fprintf(os.Stderr, "[ERROR] call to OnConfigurationChange failed, error: %v", err.Error()) + } } // Capture output of standard logger because go-plugin |