-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugins.go
43 lines (36 loc) · 1.03 KB
/
plugins.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
39
40
41
42
43
package lure
import "sync"
var (
functions map[string]IFunction
extTypes map[string]IDataFactory
once sync.Once
)
// IFunction defines the interface for customized LURE functions
type IFunction interface {
// name identifies what function this is
name() string
// derive calculates the output from the input
derive(params []IData) IData
}
// // IDataFactory defines the interface for extended data types
// type IDataFactory interface {
// create(raw string, extKey string) IData
// }
// IDataFactory is a function that can create IData
type IDataFactory = func(raw string, extKey string) IData
// getFunctions gets the plugin for functions
func getFunctions() map[string]IFunction {
once.Do(func() {
functions = make(map[string]IFunction)
functions["md5mod"] = nil
})
return functions
}
// getExtDataTypes gets the plugin for extended data types
func getExtDataTypes() map[string]IDataFactory {
once.Do(func() {
extTypes = make(map[string]IDataFactory)
extTypes["semver"] = VersionDataConstructor
})
return extTypes
}