app.go/condflow.go/cron.go/event_stream.go/executor.go/gobridge.go/grpc.go/job.go/mcp.go/mqtt.go/res_virtual_table.go/ws.go/controller.go/support/service.go 精简掉搬到 framework-v2 internal/handler 里的公共默认实现,只保留接口定义。
57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package support
|
|
|
|
import (
|
|
"plugin"
|
|
|
|
"git.fsdpf.net/go/contracts"
|
|
)
|
|
|
|
func GoPluginCore(core string, services ...any) {
|
|
p, err := plugin.Open(core)
|
|
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
for i := 0; i < len(services); i++ {
|
|
switch s := services[i].(type) {
|
|
case map[string]contracts.Controller:
|
|
if f, err := p.Lookup("RegControllers"); err != nil {
|
|
panic(err)
|
|
} else if fn, ok := f.(func(map[string]contracts.Controller) error); ok {
|
|
fn(s)
|
|
}
|
|
case map[string]contracts.ResWatcher:
|
|
if f, err := p.Lookup("RegResWatchers"); err != nil {
|
|
panic(err)
|
|
} else if fn, ok := f.(func(map[string]contracts.ResWatcher) error); ok {
|
|
fn(s)
|
|
}
|
|
case map[string]contracts.GRpc:
|
|
if f, err := p.Lookup("RegGRpcs"); err != nil {
|
|
panic(err)
|
|
} else if fn, ok := f.(func(map[string]contracts.GRpc) error); ok {
|
|
fn(s)
|
|
}
|
|
case map[string]contracts.Job:
|
|
if f, err := p.Lookup("RegJobs"); err != nil {
|
|
panic(err)
|
|
} else if fn, ok := f.(func(map[string]contracts.Job) error); ok {
|
|
fn(s)
|
|
}
|
|
case map[string]contracts.Cron:
|
|
if f, err := p.Lookup("RegCrons"); err != nil {
|
|
panic(err)
|
|
} else if fn, ok := f.(func(map[string]contracts.Cron) error); ok {
|
|
fn(s)
|
|
}
|
|
}
|
|
}
|
|
|
|
if f, err := p.Lookup("Run"); err != nil {
|
|
panic(err)
|
|
} else if fn, ok := f.(func()); ok {
|
|
fn()
|
|
}
|
|
}
|