diff --git a/support/service.go b/support/service.go new file mode 100644 index 0000000..03e1186 --- /dev/null +++ b/support/service.go @@ -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() + } +}