Commit 4f1fe325 authored by suyanlong's avatar suyanlong

Fixed plugin client init

parent 3b565572
Pipeline #8342 failed with stages
......@@ -143,6 +143,7 @@ type GRPCClient struct {
doneContext context.Context
kernel Kernel
DID string
TypeName string
}
func (g *GRPCClient) Initialize(configPath string, ID string, extra []byte) error {
......@@ -327,12 +328,13 @@ func (g *GRPCClient) Name() string {
}
func (g *GRPCClient) Type() string {
response, err := g.client.Type(g.doneContext, &pb.Empty{})
if err != nil {
return ""
}
return response.Type
//response, err := g.client.Type(g.doneContext, &pb.Empty{})
//if err != nil {
// return ""
//}
//
//return response.Type
return g.TypeName
}
func (g *GRPCClient) Bind(kern Kernel) {
......
......@@ -73,6 +73,9 @@ func CreateClients(appchainConfigs []repo.Appchain, extra []byte) []Client {
tool.Asset(err)
var clients []Client
for _, appchainConfig := range appchainConfigs {
if !appchainConfig.Enable {
continue
}
pluginConfigPath := filepath.Join(rootPath, "plugins", appchainConfig.Config)
pluginPath := filepath.Join(rootPath, "plugins", appchainConfig.Plugin)
_, err = os.Stat(pluginPath)
......@@ -99,16 +102,16 @@ func CreateClients(appchainConfigs []repo.Appchain, extra []byte) []Client {
// Request the plugin
raw, err := rpcClient.Dispense(appchainConfig.Plugin)
tool.Asset(err)
var client Client
var client *GRPCClient
switch raw.(type) {
case *GRPCClient:
client = raw.(*GRPCClient)
default:
tool.Asset(fmt.Errorf("unsupported kernel type"))
}
// initialize our kernel plugin
err = client.Initialize(pluginConfigPath, appchainConfig.DID, extra)
client.TypeName = appchainConfig.Type //TODO
tool.Asset(err)
client.Bind(kernel)
clients = append(clients, client)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment