diff --git a/support/service.go b/support/service.go index 03e1186..47e5c5c 100644 --- a/support/service.go +++ b/support/service.go @@ -6,23 +6,46 @@ import ( "git.fsdpf.net/go/contracts" ) -func GoPluginCore(core string, controllers map[string]contracts.Controller, listens map[string]contracts.ResListener) { +func GoPluginCore(core string, services ...any) { 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) + 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.ResListener: + if f, err := p.Lookup("RegListens"); err != nil { + panic(err) + } else if fn, ok := f.(func(map[string]contracts.ResListener) 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 {