This reverts commit ea61458f16. This was causing panic in the plugins because the client and the plugin API changed with this PR
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
26b86cb3ef
Коммит
c0971970e9
@@ -118,8 +118,8 @@ var _ Hooks = &hooksRPCClient{}
|
||||
func (g *hooksRPCClient) Implemented() (impl []string, err error) {
|
||||
err = g.client.Call("Plugin.Implemented", struct{}{}, &impl)
|
||||
for _, hookName := range impl {
|
||||
if hookID, ok := hookNameToId[hookName]; ok {
|
||||
g.implemented[hookID] = true
|
||||
if hookId, ok := hookNameToId[hookName]; ok {
|
||||
g.implemented[hookId] = true
|
||||
}
|
||||
}
|
||||
return
|
||||
@@ -166,25 +166,25 @@ func (s *hooksRPCServer) Implemented(args struct{}, reply *[]string) error {
|
||||
return encodableError(nil)
|
||||
}
|
||||
|
||||
type ZOnActivateArgs struct {
|
||||
APIMuxID uint32
|
||||
type Z_OnActivateArgs struct {
|
||||
APIMuxId uint32
|
||||
}
|
||||
|
||||
type ZOnActivateReturns struct {
|
||||
type Z_OnActivateReturns struct {
|
||||
A error
|
||||
}
|
||||
|
||||
func (g *hooksRPCClient) OnActivate() error {
|
||||
muxID := g.muxBroker.NextId()
|
||||
go g.muxBroker.AcceptAndServe(muxID, &apiRPCServer{
|
||||
muxId := g.muxBroker.NextId()
|
||||
go g.muxBroker.AcceptAndServe(muxId, &apiRPCServer{
|
||||
impl: g.apiImpl,
|
||||
muxBroker: g.muxBroker,
|
||||
})
|
||||
|
||||
_args := &ZOnActivateArgs{
|
||||
APIMuxID: muxID,
|
||||
_args := &Z_OnActivateArgs{
|
||||
APIMuxId: muxId,
|
||||
}
|
||||
_returns := &ZOnActivateReturns{}
|
||||
_returns := &Z_OnActivateReturns{}
|
||||
|
||||
if err := g.client.Call("Plugin.OnActivate", _args, _returns); err != nil {
|
||||
g.log.Error("RPC call to OnActivate plugin failed.", mlog.Err(err))
|
||||
@@ -192,8 +192,8 @@ func (g *hooksRPCClient) OnActivate() error {
|
||||
return _returns.A
|
||||
}
|
||||
|
||||
func (s *hooksRPCServer) OnActivate(args *ZOnActivateArgs, returns *ZOnActivateReturns) error {
|
||||
connection, err := s.muxBroker.Dial(args.APIMuxID)
|
||||
func (s *hooksRPCServer) OnActivate(args *Z_OnActivateArgs, returns *Z_OnActivateReturns) error {
|
||||
connection, err := s.muxBroker.Dial(args.APIMuxId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -231,16 +231,16 @@ func (s *hooksRPCServer) OnActivate(args *ZOnActivateArgs, returns *ZOnActivateR
|
||||
return nil
|
||||
}
|
||||
|
||||
type ZLoadPluginConfigurationArgsArgs struct {
|
||||
type Z_LoadPluginConfigurationArgsArgs struct {
|
||||
}
|
||||
|
||||
type ZLoadPluginConfigurationArgsReturns struct {
|
||||
type Z_LoadPluginConfigurationArgsReturns struct {
|
||||
A []byte
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) LoadPluginConfiguration(dest interface{}) error {
|
||||
_args := &ZLoadPluginConfigurationArgsArgs{}
|
||||
_returns := &ZLoadPluginConfigurationArgsReturns{}
|
||||
_args := &Z_LoadPluginConfigurationArgsArgs{}
|
||||
_returns := &Z_LoadPluginConfigurationArgsReturns{}
|
||||
if err := g.client.Call("Plugin.LoadPluginConfiguration", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to LoadPluginConfiguration API failed: %s", err.Error())
|
||||
}
|
||||
@@ -250,7 +250,7 @@ func (g *apiRPCClient) LoadPluginConfiguration(dest interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) LoadPluginConfiguration(args *ZLoadPluginConfigurationArgsArgs, returns *ZLoadPluginConfigurationArgsReturns) error {
|
||||
func (s *apiRPCServer) LoadPluginConfiguration(args *Z_LoadPluginConfigurationArgsArgs, returns *Z_LoadPluginConfigurationArgsReturns) error {
|
||||
var config interface{}
|
||||
if hook, ok := s.impl.(interface {
|
||||
LoadPluginConfiguration(dest interface{}) error
|
||||
@@ -271,7 +271,7 @@ func init() {
|
||||
hookNameToId["ServeHTTP"] = ServeHTTPID
|
||||
}
|
||||
|
||||
type ZServeHTTPArgs struct {
|
||||
type Z_ServeHTTPArgs struct {
|
||||
ResponseWriterStream uint32
|
||||
Request *http.Request
|
||||
Context *Context
|
||||
@@ -284,11 +284,11 @@ func (g *hooksRPCClient) ServeHTTP(c *Context, w http.ResponseWriter, r *http.Re
|
||||
return
|
||||
}
|
||||
|
||||
serveHTTPStreamID := g.muxBroker.NextId()
|
||||
serveHTTPStreamId := g.muxBroker.NextId()
|
||||
go func() {
|
||||
connection, err := g.muxBroker.Accept(serveHTTPStreamID)
|
||||
connection, err := g.muxBroker.Accept(serveHTTPStreamId)
|
||||
if err != nil {
|
||||
g.log.Error("Plugin failed to ServeHTTP, muxBroker couldn't accept connection", mlog.Uint32("serve_http_stream_id", serveHTTPStreamID), mlog.Err(err))
|
||||
g.log.Error("Plugin failed to ServeHTTP, muxBroker couldn't accept connection", mlog.Uint32("serve_http_stream_id", serveHTTPStreamId), mlog.Err(err))
|
||||
return
|
||||
}
|
||||
defer connection.Close()
|
||||
@@ -301,11 +301,11 @@ func (g *hooksRPCClient) ServeHTTP(c *Context, w http.ResponseWriter, r *http.Re
|
||||
rpcServer.ServeConn(connection)
|
||||
}()
|
||||
|
||||
requestBodyStreamID := uint32(0)
|
||||
requestBodyStreamId := uint32(0)
|
||||
if r.Body != nil {
|
||||
requestBodyStreamID = g.muxBroker.NextId()
|
||||
requestBodyStreamId = g.muxBroker.NextId()
|
||||
go func() {
|
||||
bodyConnection, err := g.muxBroker.Accept(requestBodyStreamID)
|
||||
bodyConnection, err := g.muxBroker.Accept(requestBodyStreamId)
|
||||
if err != nil {
|
||||
g.log.Error("Plugin failed to ServeHTTP, muxBroker couldn't Accept request body connection", mlog.Err(err))
|
||||
return
|
||||
@@ -327,18 +327,18 @@ func (g *hooksRPCClient) ServeHTTP(c *Context, w http.ResponseWriter, r *http.Re
|
||||
RequestURI: r.RequestURI,
|
||||
}
|
||||
|
||||
if err := g.client.Call("Plugin.ServeHTTP", ZServeHTTPArgs{
|
||||
if err := g.client.Call("Plugin.ServeHTTP", Z_ServeHTTPArgs{
|
||||
Context: c,
|
||||
ResponseWriterStream: serveHTTPStreamID,
|
||||
ResponseWriterStream: serveHTTPStreamId,
|
||||
Request: forwardedRequest,
|
||||
RequestBodyStream: requestBodyStreamID,
|
||||
RequestBodyStream: requestBodyStreamId,
|
||||
}, nil); err != nil {
|
||||
g.log.Error("Plugin failed to ServeHTTP, RPC call failed", mlog.Err(err))
|
||||
http.Error(w, "500 internal server error", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *hooksRPCServer) ServeHTTP(args *ZServeHTTPArgs, returns *struct{}) error {
|
||||
func (s *hooksRPCServer) ServeHTTP(args *Z_ServeHTTPArgs, returns *struct{}) error {
|
||||
connection, err := s.muxBroker.Dial(args.ResponseWriterStream)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "[ERROR] Can't connect to remote response writer stream, error: %v", err.Error())
|
||||
@@ -371,12 +371,12 @@ func (s *hooksRPCServer) ServeHTTP(args *ZServeHTTPArgs, returns *struct{}) erro
|
||||
return nil
|
||||
}
|
||||
|
||||
type ZPluginHTTPArgs struct {
|
||||
type Z_PluginHTTPArgs struct {
|
||||
Request *http.Request
|
||||
RequestBody []byte
|
||||
}
|
||||
|
||||
type ZPluginHTTPReturns struct {
|
||||
type Z_PluginHTTPReturns struct {
|
||||
Response *http.Response
|
||||
ResponseBody []byte
|
||||
}
|
||||
@@ -402,12 +402,12 @@ func (g *apiRPCClient) PluginHTTP(request *http.Request) *http.Response {
|
||||
request.Body.Close()
|
||||
request.Body = nil
|
||||
|
||||
_args := &ZPluginHTTPArgs{
|
||||
_args := &Z_PluginHTTPArgs{
|
||||
Request: forwardedRequest,
|
||||
RequestBody: requestBody,
|
||||
}
|
||||
|
||||
_returns := &ZPluginHTTPReturns{}
|
||||
_returns := &Z_PluginHTTPReturns{}
|
||||
if err := g.client.Call("Plugin.PluginHTTP", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to PluginHTTP API failed: %s", err.Error())
|
||||
return nil
|
||||
@@ -418,7 +418,7 @@ func (g *apiRPCClient) PluginHTTP(request *http.Request) *http.Response {
|
||||
return _returns.Response
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) PluginHTTP(args *ZPluginHTTPArgs, returns *ZPluginHTTPReturns) error {
|
||||
func (s *apiRPCServer) PluginHTTP(args *Z_PluginHTTPArgs, returns *Z_PluginHTTPReturns) error {
|
||||
args.Request.Body = ioutil.NopCloser(bytes.NewBuffer(args.RequestBody))
|
||||
|
||||
if hook, ok := s.impl.(interface {
|
||||
@@ -445,14 +445,14 @@ func init() {
|
||||
hookNameToId["FileWillBeUploaded"] = FileWillBeUploadedID
|
||||
}
|
||||
|
||||
type ZFileWillBeUploadedArgs struct {
|
||||
type Z_FileWillBeUploadedArgs struct {
|
||||
A *Context
|
||||
B *model.FileInfo
|
||||
UploadedFileStream uint32
|
||||
ReplacementFileStream uint32
|
||||
}
|
||||
|
||||
type ZFileWillBeUploadedReturns struct {
|
||||
type Z_FileWillBeUploadedReturns struct {
|
||||
A *model.FileInfo
|
||||
B string
|
||||
}
|
||||
@@ -462,9 +462,9 @@ func (g *hooksRPCClient) FileWillBeUploaded(c *Context, info *model.FileInfo, fi
|
||||
return info, ""
|
||||
}
|
||||
|
||||
uploadedFileStreamID := g.muxBroker.NextId()
|
||||
uploadedFileStreamId := g.muxBroker.NextId()
|
||||
go func() {
|
||||
uploadedFileConnection, err := g.muxBroker.Accept(uploadedFileStreamID)
|
||||
uploadedFileConnection, err := g.muxBroker.Accept(uploadedFileStreamId)
|
||||
if err != nil {
|
||||
g.log.Error("Plugin failed to serve upload file stream. MuxBroker could not Accept connection", mlog.Err(err))
|
||||
return
|
||||
@@ -474,11 +474,11 @@ func (g *hooksRPCClient) FileWillBeUploaded(c *Context, info *model.FileInfo, fi
|
||||
}()
|
||||
|
||||
replacementDone := make(chan bool)
|
||||
replacementFileStreamID := g.muxBroker.NextId()
|
||||
replacementFileStreamId := g.muxBroker.NextId()
|
||||
go func() {
|
||||
defer close(replacementDone)
|
||||
|
||||
replacementFileConnection, err := g.muxBroker.Accept(replacementFileStreamID)
|
||||
replacementFileConnection, err := g.muxBroker.Accept(replacementFileStreamId)
|
||||
if err != nil {
|
||||
g.log.Error("Plugin failed to serve replacement file stream. MuxBroker could not Accept connection", mlog.Err(err))
|
||||
return
|
||||
@@ -489,8 +489,8 @@ func (g *hooksRPCClient) FileWillBeUploaded(c *Context, info *model.FileInfo, fi
|
||||
}
|
||||
}()
|
||||
|
||||
_args := &ZFileWillBeUploadedArgs{c, info, uploadedFileStreamID, replacementFileStreamID}
|
||||
_returns := &ZFileWillBeUploadedReturns{A: _args.B}
|
||||
_args := &Z_FileWillBeUploadedArgs{c, info, uploadedFileStreamId, replacementFileStreamId}
|
||||
_returns := &Z_FileWillBeUploadedReturns{A: _args.B}
|
||||
if err := g.client.Call("Plugin.FileWillBeUploaded", _args, _returns); err != nil {
|
||||
g.log.Error("RPC call FileWillBeUploaded to plugin failed.", mlog.Err(err))
|
||||
}
|
||||
@@ -501,7 +501,7 @@ func (g *hooksRPCClient) FileWillBeUploaded(c *Context, info *model.FileInfo, fi
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *hooksRPCServer) FileWillBeUploaded(args *ZFileWillBeUploadedArgs, returns *ZFileWillBeUploadedReturns) error {
|
||||
func (s *hooksRPCServer) FileWillBeUploaded(args *Z_FileWillBeUploadedArgs, returns *Z_FileWillBeUploadedReturns) error {
|
||||
uploadFileConnection, err := s.muxBroker.Dial(args.UploadedFileStream)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "[ERROR] Can't connect to remote upload file stream, error: %v", err.Error())
|
||||
@@ -536,19 +536,19 @@ func init() {
|
||||
hookNameToId["MessageWillBePosted"] = MessageWillBePostedID
|
||||
}
|
||||
|
||||
type ZMessageWillBePostedArgs struct {
|
||||
type Z_MessageWillBePostedArgs struct {
|
||||
A *Context
|
||||
B *model.Post
|
||||
}
|
||||
|
||||
type ZMessageWillBePostedReturns struct {
|
||||
type Z_MessageWillBePostedReturns struct {
|
||||
A *model.Post
|
||||
B string
|
||||
}
|
||||
|
||||
func (g *hooksRPCClient) MessageWillBePosted(c *Context, post *model.Post) (*model.Post, string) {
|
||||
_args := &ZMessageWillBePostedArgs{c, post}
|
||||
_returns := &ZMessageWillBePostedReturns{A: _args.B}
|
||||
_args := &Z_MessageWillBePostedArgs{c, post}
|
||||
_returns := &Z_MessageWillBePostedReturns{A: _args.B}
|
||||
if g.implemented[MessageWillBePostedID] {
|
||||
if err := g.client.Call("Plugin.MessageWillBePosted", _args, _returns); err != nil {
|
||||
g.log.Error("RPC call MessageWillBePosted to plugin failed.", mlog.Err(err))
|
||||
@@ -557,7 +557,7 @@ func (g *hooksRPCClient) MessageWillBePosted(c *Context, post *model.Post) (*mod
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *hooksRPCServer) MessageWillBePosted(args *ZMessageWillBePostedArgs, returns *ZMessageWillBePostedReturns) error {
|
||||
func (s *hooksRPCServer) MessageWillBePosted(args *Z_MessageWillBePostedArgs, returns *Z_MessageWillBePostedReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
MessageWillBePosted(c *Context, post *model.Post) (*model.Post, string)
|
||||
}); ok {
|
||||
@@ -576,20 +576,20 @@ func init() {
|
||||
hookNameToId["MessageWillBeUpdated"] = MessageWillBeUpdatedID
|
||||
}
|
||||
|
||||
type ZMessageWillBeUpdatedArgs struct {
|
||||
type Z_MessageWillBeUpdatedArgs struct {
|
||||
A *Context
|
||||
B *model.Post
|
||||
C *model.Post
|
||||
}
|
||||
|
||||
type ZMessageWillBeUpdatedReturns struct {
|
||||
type Z_MessageWillBeUpdatedReturns struct {
|
||||
A *model.Post
|
||||
B string
|
||||
}
|
||||
|
||||
func (g *hooksRPCClient) MessageWillBeUpdated(c *Context, newPost, oldPost *model.Post) (*model.Post, string) {
|
||||
_args := &ZMessageWillBeUpdatedArgs{c, newPost, oldPost}
|
||||
_returns := &ZMessageWillBeUpdatedReturns{A: _args.B}
|
||||
_args := &Z_MessageWillBeUpdatedArgs{c, newPost, oldPost}
|
||||
_returns := &Z_MessageWillBeUpdatedReturns{A: _args.B}
|
||||
if g.implemented[MessageWillBeUpdatedID] {
|
||||
if err := g.client.Call("Plugin.MessageWillBeUpdated", _args, _returns); err != nil {
|
||||
g.log.Error("RPC call MessageWillBeUpdated to plugin failed.", mlog.Err(err))
|
||||
@@ -598,7 +598,7 @@ func (g *hooksRPCClient) MessageWillBeUpdated(c *Context, newPost, oldPost *mode
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *hooksRPCServer) MessageWillBeUpdated(args *ZMessageWillBeUpdatedArgs, returns *ZMessageWillBeUpdatedReturns) error {
|
||||
func (s *hooksRPCServer) MessageWillBeUpdated(args *Z_MessageWillBeUpdatedArgs, returns *Z_MessageWillBeUpdatedReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
MessageWillBeUpdated(c *Context, newPost, oldPost *model.Post) (*model.Post, string)
|
||||
}); ok {
|
||||
@@ -610,25 +610,25 @@ func (s *hooksRPCServer) MessageWillBeUpdated(args *ZMessageWillBeUpdatedArgs, r
|
||||
return nil
|
||||
}
|
||||
|
||||
type ZLogDebugArgs struct {
|
||||
type Z_LogDebugArgs struct {
|
||||
A string
|
||||
B []interface{}
|
||||
}
|
||||
|
||||
type ZLogDebugReturns struct {
|
||||
type Z_LogDebugReturns struct {
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) LogDebug(msg string, keyValuePairs ...interface{}) {
|
||||
stringifiedPairs := stringifyToObjects(keyValuePairs)
|
||||
_args := &ZLogDebugArgs{msg, stringifiedPairs}
|
||||
_returns := &ZLogDebugReturns{}
|
||||
_args := &Z_LogDebugArgs{msg, stringifiedPairs}
|
||||
_returns := &Z_LogDebugReturns{}
|
||||
if err := g.client.Call("Plugin.LogDebug", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to LogDebug API failed: %s", err.Error())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) LogDebug(args *ZLogDebugArgs, returns *ZLogDebugReturns) error {
|
||||
func (s *apiRPCServer) LogDebug(args *Z_LogDebugArgs, returns *Z_LogDebugReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
LogDebug(msg string, keyValuePairs ...interface{})
|
||||
}); ok {
|
||||
@@ -639,25 +639,25 @@ func (s *apiRPCServer) LogDebug(args *ZLogDebugArgs, returns *ZLogDebugReturns)
|
||||
return nil
|
||||
}
|
||||
|
||||
type ZLogInfoArgs struct {
|
||||
type Z_LogInfoArgs struct {
|
||||
A string
|
||||
B []interface{}
|
||||
}
|
||||
|
||||
type ZLogInfoReturns struct {
|
||||
type Z_LogInfoReturns struct {
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) LogInfo(msg string, keyValuePairs ...interface{}) {
|
||||
stringifiedPairs := stringifyToObjects(keyValuePairs)
|
||||
_args := &ZLogInfoArgs{msg, stringifiedPairs}
|
||||
_returns := &ZLogInfoReturns{}
|
||||
_args := &Z_LogInfoArgs{msg, stringifiedPairs}
|
||||
_returns := &Z_LogInfoReturns{}
|
||||
if err := g.client.Call("Plugin.LogInfo", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to LogInfo API failed: %s", err.Error())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) LogInfo(args *ZLogInfoArgs, returns *ZLogInfoReturns) error {
|
||||
func (s *apiRPCServer) LogInfo(args *Z_LogInfoArgs, returns *Z_LogInfoReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
LogInfo(msg string, keyValuePairs ...interface{})
|
||||
}); ok {
|
||||
@@ -668,25 +668,25 @@ func (s *apiRPCServer) LogInfo(args *ZLogInfoArgs, returns *ZLogInfoReturns) err
|
||||
return nil
|
||||
}
|
||||
|
||||
type ZLogWarnArgs struct {
|
||||
type Z_LogWarnArgs struct {
|
||||
A string
|
||||
B []interface{}
|
||||
}
|
||||
|
||||
type ZLogWarnReturns struct {
|
||||
type Z_LogWarnReturns struct {
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) LogWarn(msg string, keyValuePairs ...interface{}) {
|
||||
stringifiedPairs := stringifyToObjects(keyValuePairs)
|
||||
_args := &ZLogWarnArgs{msg, stringifiedPairs}
|
||||
_returns := &ZLogWarnReturns{}
|
||||
_args := &Z_LogWarnArgs{msg, stringifiedPairs}
|
||||
_returns := &Z_LogWarnReturns{}
|
||||
if err := g.client.Call("Plugin.LogWarn", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to LogWarn API failed: %s", err.Error())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) LogWarn(args *ZLogWarnArgs, returns *ZLogWarnReturns) error {
|
||||
func (s *apiRPCServer) LogWarn(args *Z_LogWarnArgs, returns *Z_LogWarnReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
LogWarn(msg string, keyValuePairs ...interface{})
|
||||
}); ok {
|
||||
@@ -697,24 +697,24 @@ func (s *apiRPCServer) LogWarn(args *ZLogWarnArgs, returns *ZLogWarnReturns) err
|
||||
return nil
|
||||
}
|
||||
|
||||
type ZLogErrorArgs struct {
|
||||
type Z_LogErrorArgs struct {
|
||||
A string
|
||||
B []interface{}
|
||||
}
|
||||
|
||||
type ZLogErrorReturns struct {
|
||||
type Z_LogErrorReturns struct {
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) LogError(msg string, keyValuePairs ...interface{}) {
|
||||
stringifiedPairs := stringifyToObjects(keyValuePairs)
|
||||
_args := &ZLogErrorArgs{msg, stringifiedPairs}
|
||||
_returns := &ZLogErrorReturns{}
|
||||
_args := &Z_LogErrorArgs{msg, stringifiedPairs}
|
||||
_returns := &Z_LogErrorReturns{}
|
||||
if err := g.client.Call("Plugin.LogError", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to LogError API failed: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) LogError(args *ZLogErrorArgs, returns *ZLogErrorReturns) error {
|
||||
func (s *apiRPCServer) LogError(args *Z_LogErrorArgs, returns *Z_LogErrorReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
LogError(msg string, keyValuePairs ...interface{})
|
||||
}); ok {
|
||||
@@ -725,12 +725,12 @@ func (s *apiRPCServer) LogError(args *ZLogErrorArgs, returns *ZLogErrorReturns)
|
||||
return nil
|
||||
}
|
||||
|
||||
type ZInstallPluginArgs struct {
|
||||
type Z_InstallPluginArgs struct {
|
||||
PluginStreamID uint32
|
||||
B bool
|
||||
}
|
||||
|
||||
type ZInstallPluginReturns struct {
|
||||
type Z_InstallPluginReturns struct {
|
||||
A *model.Manifest
|
||||
B *model.AppError
|
||||
}
|
||||
@@ -748,8 +748,8 @@ func (g *apiRPCClient) InstallPlugin(file io.Reader, replace bool) (*model.Manif
|
||||
serveIOReader(file, uploadPluginConnection)
|
||||
}()
|
||||
|
||||
_args := &ZInstallPluginArgs{pluginStreamID, replace}
|
||||
_returns := &ZInstallPluginReturns{}
|
||||
_args := &Z_InstallPluginArgs{pluginStreamID, replace}
|
||||
_returns := &Z_InstallPluginReturns{}
|
||||
if err := g.client.Call("Plugin.InstallPlugin", _args, _returns); err != nil {
|
||||
log.Print("RPC call InstallPlugin to plugin failed.", mlog.Err(err))
|
||||
}
|
||||
@@ -757,7 +757,7 @@ func (g *apiRPCClient) InstallPlugin(file io.Reader, replace bool) (*model.Manif
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) InstallPlugin(args *ZInstallPluginArgs, returns *ZInstallPluginReturns) error {
|
||||
func (s *apiRPCServer) InstallPlugin(args *Z_InstallPluginArgs, returns *Z_InstallPluginReturns) error {
|
||||
hook, ok := s.impl.(interface {
|
||||
InstallPlugin(file io.Reader, replace bool) (*model.Manifest, *model.AppError)
|
||||
})
|
||||
|
||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -191,14 +191,14 @@ func (env *Environment) Statuses() (model.PluginStatuses, error) {
|
||||
|
||||
// GetManifest returns a manifest for a given pluginId.
|
||||
// Returns ErrNotFound if plugin is not found.
|
||||
func (env *Environment) GetManifest(pluginID string) (*model.Manifest, error) {
|
||||
func (env *Environment) GetManifest(pluginId string) (*model.Manifest, error) {
|
||||
plugins, err := env.Available()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "unable to get plugin statuses")
|
||||
}
|
||||
|
||||
for _, plugin := range plugins {
|
||||
if plugin.Manifest != nil && plugin.Manifest.Id == pluginID {
|
||||
if plugin.Manifest != nil && plugin.Manifest.Id == pluginId {
|
||||
return plugin.Manifest, nil
|
||||
}
|
||||
}
|
||||
@@ -447,13 +447,13 @@ func (env *Environment) HooksForPlugin(id string) (Hooks, error) {
|
||||
//
|
||||
// If hookRunnerFunc returns false, iteration will not continue. The iteration order among active
|
||||
// plugins is not specified.
|
||||
func (env *Environment) RunMultiPluginHook(hookRunnerFunc func(hooks Hooks) bool, hookID int) {
|
||||
func (env *Environment) RunMultiPluginHook(hookRunnerFunc func(hooks Hooks) bool, hookId int) {
|
||||
startTime := time.Now()
|
||||
|
||||
env.registeredPlugins.Range(func(key, value interface{}) bool {
|
||||
rp := value.(registeredPlugin)
|
||||
|
||||
if rp.supervisor == nil || !rp.supervisor.Implements(hookID) || !env.IsActive(rp.BundleInfo.Manifest.Id) {
|
||||
if rp.supervisor == nil || !rp.supervisor.Implements(hookId) || !env.IsActive(rp.BundleInfo.Manifest.Id) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -470,7 +470,7 @@ func generateHooksGlue(info *PluginInterfaceInfo) {
|
||||
return FieldListToRecordSuccess(structPrefix, fields)
|
||||
},
|
||||
"obscure": func(name string) string {
|
||||
return "Z" + name
|
||||
return "Z_" + name
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -89,8 +89,8 @@ func newSupervisor(pluginInfo *model.BundleInfo, apiImpl API, parentLogger *mlog
|
||||
return nil, err
|
||||
}
|
||||
for _, hookName := range impl {
|
||||
if hookID, ok := hookNameToId[hookName]; ok {
|
||||
sup.implemented[hookID] = true
|
||||
if hookId, ok := hookNameToId[hookName]; ok {
|
||||
sup.implemented[hookId] = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,8 +141,8 @@ func (sup *supervisor) Ping() error {
|
||||
return client.Ping()
|
||||
}
|
||||
|
||||
func (sup *supervisor) Implements(hookID int) bool {
|
||||
func (sup *supervisor) Implements(hookId int) bool {
|
||||
sup.lock.RLock()
|
||||
defer sup.lock.RUnlock()
|
||||
return sup.implemented[hookID]
|
||||
return sup.implemented[hookId]
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user