| 5 | import "strings" |
| 6 | |
| 7 | func (m *Manager) Register(name string, fn func(Function)) { |
| 8 | if fn == nil { |
| 9 | m.Warningf("not registering '%s': nil function", name) |
| 10 | return |
| 11 | } |
| 12 | |
| 13 | m.mux.Lock() |
| 14 | defer m.mux.Unlock() |
| 15 | |
| 16 | fs, ok := m.functionRegistry[name] |
| 17 | if !ok { |
| 18 | m.Debugf("registering function '%s' (direct)", name) |
| 19 | fs = &functionSet{prefixes: make(map[string]func(Function))} |
| 20 | m.functionRegistry[name] = fs |
| 21 | } else { |
| 22 | if fs.direct != nil { |
| 23 | m.Warningf("re-registering direct function '%s'", name) |
| 24 | } else { |
| 25 | m.Debugf("registering function '%s' (direct)", name) |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | fs.direct = fn |
| 30 | } |
| 31 | |
| 32 | func (m *Manager) Unregister(name string) { |
| 33 | m.mux.Lock() |