config 动态加载进来了的,没法初始化的加载进去,麻烦,直接传递过来

This commit is contained in:
李子铭 2024-08-07 16:41:37 +08:00
parent 65ddbab658
commit 622a368a25
3 changed files with 8 additions and 12 deletions

View File

@ -11,7 +11,7 @@ func Order(ctx context.Context, tag string, request *proto.OrderRequest) (*proto
if err != nil { if err != nil {
return nil, err return nil, err
} }
request.Config = srv.Config //request.Config = srv.Config
return srv.Impl.Order(ctx, request) return srv.Impl.Order(ctx, request)
} }
@ -20,7 +20,6 @@ func Query(ctx context.Context, tag string, request *proto.QueryRequest) (*proto
if err != nil { if err != nil {
return nil, err return nil, err
} }
request.Config = srv.Config
return srv.Impl.Query(ctx, request) return srv.Impl.Query(ctx, request)
} }
@ -29,6 +28,5 @@ func Notify(ctx context.Context, tag string, request *proto.NotifyRequest) (*pro
if err != nil { if err != nil {
return nil, err return nil, err
} }
request.Config = srv.Config
return srv.Impl.Notify(ctx, request) return srv.Impl.Notify(ctx, request)
} }

View File

@ -1,7 +1,6 @@
package manage package manage
import ( import (
"encoding/json"
"fmt" "fmt"
"gitea.cdlsxd.cn/BaseSystem/plugin/shared" "gitea.cdlsxd.cn/BaseSystem/plugin/shared"
"github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10"
@ -20,7 +19,7 @@ type Config struct {
Timeout time.Duration // 插件超时时间 Timeout time.Duration // 插件超时时间
// 供应商配置 // 供应商配置
Config json.RawMessage // Config json.RawMessage
} }
func (c *Config) Validate() error { func (c *Config) Validate() error {

View File

@ -1,15 +1,14 @@
package manage package manage
import ( import (
"encoding/json"
"fmt" "fmt"
"gitea.cdlsxd.cn/BaseSystem/plugin/shared" "gitea.cdlsxd.cn/BaseSystem/plugin/shared"
) )
type PluginInfo struct { type PluginInfo struct {
Tag string Tag string
Impl shared.PluginService Impl shared.PluginService
Config json.RawMessage //Config json.RawMessage
cleanup func() cleanup func()
} }
@ -34,9 +33,9 @@ func (m *pluginManage) add(c *Config) error {
return err return err
} }
m.plugins[c.Tag] = &PluginInfo{ m.plugins[c.Tag] = &PluginInfo{
Tag: c.Tag, Tag: c.Tag,
Impl: impl, Impl: impl,
Config: c.Config, //Config: c.Config,
cleanup: cleanup, cleanup: cleanup,
} }
return nil return nil