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 { ...@@ -143,6 +143,7 @@ type GRPCClient struct {
doneContext context.Context doneContext context.Context
kernel Kernel kernel Kernel
DID string DID string
TypeName string
} }
func (g *GRPCClient) Initialize(configPath string, ID string, extra []byte) error { func (g *GRPCClient) Initialize(configPath string, ID string, extra []byte) error {
...@@ -327,12 +328,13 @@ func (g *GRPCClient) Name() string { ...@@ -327,12 +328,13 @@ func (g *GRPCClient) Name() string {
} }
func (g *GRPCClient) Type() string { func (g *GRPCClient) Type() string {
response, err := g.client.Type(g.doneContext, &pb.Empty{}) //response, err := g.client.Type(g.doneContext, &pb.Empty{})
if err != nil { //if err != nil {
return "" // return ""
} //}
//
return response.Type //return response.Type
return g.TypeName
} }
func (g *GRPCClient) Bind(kern Kernel) { func (g *GRPCClient) Bind(kern Kernel) {
......
...@@ -73,6 +73,9 @@ func CreateClients(appchainConfigs []repo.Appchain, extra []byte) []Client { ...@@ -73,6 +73,9 @@ func CreateClients(appchainConfigs []repo.Appchain, extra []byte) []Client {
tool.Asset(err) tool.Asset(err)
var clients []Client var clients []Client
for _, appchainConfig := range appchainConfigs { for _, appchainConfig := range appchainConfigs {
if !appchainConfig.Enable {
continue
}
pluginConfigPath := filepath.Join(rootPath, "plugins", appchainConfig.Config) pluginConfigPath := filepath.Join(rootPath, "plugins", appchainConfig.Config)
pluginPath := filepath.Join(rootPath, "plugins", appchainConfig.Plugin) pluginPath := filepath.Join(rootPath, "plugins", appchainConfig.Plugin)
_, err = os.Stat(pluginPath) _, err = os.Stat(pluginPath)
...@@ -99,16 +102,16 @@ func CreateClients(appchainConfigs []repo.Appchain, extra []byte) []Client { ...@@ -99,16 +102,16 @@ func CreateClients(appchainConfigs []repo.Appchain, extra []byte) []Client {
// Request the plugin // Request the plugin
raw, err := rpcClient.Dispense(appchainConfig.Plugin) raw, err := rpcClient.Dispense(appchainConfig.Plugin)
tool.Asset(err) tool.Asset(err)
var client Client var client *GRPCClient
switch raw.(type) { switch raw.(type) {
case *GRPCClient: case *GRPCClient:
client = raw.(*GRPCClient) client = raw.(*GRPCClient)
default: default:
tool.Asset(fmt.Errorf("unsupported kernel type")) tool.Asset(fmt.Errorf("unsupported kernel type"))
} }
// initialize our kernel plugin // initialize our kernel plugin
err = client.Initialize(pluginConfigPath, appchainConfig.DID, extra) err = client.Initialize(pluginConfigPath, appchainConfig.DID, extra)
client.TypeName = appchainConfig.Type //TODO
tool.Asset(err) tool.Asset(err)
client.Bind(kernel) client.Bind(kernel)
clients = append(clients, client) 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