char/pkg/register/plugin_client.go

30 lines
454 B
Go
Raw Normal View History

2022-11-01 14:26:54 +01:00
package register
import (
2022-11-01 21:15:32 +01:00
"context"
"encoding/json"
2022-11-01 14:26:54 +01:00
"net/rpc"
)
type PluginClient struct {
client *rpc.Client
}
var _ Plugin = &PluginClient{}
2022-11-01 21:15:32 +01:00
func (pc *PluginClient) About(ctx context.Context) (*About, error) {
2022-11-01 14:26:54 +01:00
var resp string
err := pc.client.Call("Plugin.About", new(any), &resp)
if err != nil {
2022-11-01 21:15:32 +01:00
return nil, err
2022-11-01 14:26:54 +01:00
}
2022-11-01 21:15:32 +01:00
var about About
err = json.Unmarshal([]byte(resp), &about)
if err != nil {
return nil, err
}
return &about, nil
2022-11-01 14:26:54 +01:00
}