[feat] add support.GoPluginCore 方法
This commit is contained in:
parent
2c1a864de4
commit
a1104e57d8
33
support/service.go
Normal file
33
support/service.go
Normal file
@ -0,0 +1,33 @@
|
||||
package support
|
||||
|
||||
import (
|
||||
"plugin"
|
||||
|
||||
"git.fsdpf.net/go/contracts"
|
||||
)
|
||||
|
||||
func GoPluginCore(core string, controllers map[string]contracts.Controller, listens map[string]contracts.ResListener) {
|
||||
p, err := plugin.Open(core)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if f, err := p.Lookup("RegControllers"); err != nil {
|
||||
panic(err)
|
||||
} else if fn, ok := f.(func(map[string]contracts.Controller) error); ok {
|
||||
fn(controllers)
|
||||
}
|
||||
|
||||
if f, err := p.Lookup("RegListens"); err != nil {
|
||||
panic(err)
|
||||
} else if fn, ok := f.(func(map[string]contracts.ResListener) error); ok {
|
||||
fn(listens)
|
||||
}
|
||||
|
||||
if f, err := p.Lookup("Run"); err != nil {
|
||||
panic(err)
|
||||
} else if fn, ok := f.(func()); ok {
|
||||
fn()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user