-
Notifications
You must be signed in to change notification settings - Fork 35
/
registry.go
38 lines (29 loc) · 1.2 KB
/
registry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package endly
import (
"github.com/pkg/errors"
"github.com/viant/toolbox/data"
)
// PredefinedUdfs represents a udf registry
var PredefinedUdfs = make(map[string]func(source interface{}, state data.Map) (interface{}, error))
// UdfRegistryProvider represents udf registry provider (i.e. to register parameterized udf dynamically)
var UdfRegistryProvider = make(map[string]func(args ...interface{}) (func(source interface{}, state data.Map) (interface{}, error), error))
type UdfProvider struct {
ID string `description:"id for new udf registration"`
Provider string `description:"provider name"`
Params []interface{} `description:"provider parameters"`
}
// ServiceProvider represents a service provider
type ServiceProvider func() Service
// ServiceRegistry represents a service registry
type ServiceRegistry []ServiceProvider
// Register register service provider.
func (r *ServiceRegistry) Register(serviceProvider ServiceProvider) error {
if serviceProvider == nil {
return errors.New("provider was empty")
}
*r = append(*r, serviceProvider)
return nil
}
var registry ServiceRegistry = make([]ServiceProvider, 0)
// Registry global service provider registry
var Registry = ®istry