func CopyGlobalSourceCreatorRegistry() (SourceCreatorRegistry, error) {
	r := NewDefaultSourceCreatorRegistry()
	m, err := globalSourceCreatorRegistry.List()
	if err != nil {
		return nil, err
	}
	for t, c := range m {
		if err := r.Register(t, c); err != nil {
			return nil, err
		}
	}
	return r, nil
}
CopyGlobalSourceCreatorRegistry creates a new independent copy of the global
SourceCreatorRegistry.
package bql
import (
	"fmt"
	"gopkg.in/sensorbee/sensorbee.v0/core"
	"gopkg.in/sensorbee/sensorbee.v0/data"
	"strings"
	"sync"
)
type IOParams struct {
	TypeName string
	Name string
}
type SourceCreator interface {
	CreateSource(ctx *core.Context, ioParams *IOParams, params data.Map) (core.Source, error)
}
type sourceCreatorFunc func(*core.Context, *IOParams, data.Map) (core.Source, error)
func (f sourceCreatorFunc) CreateSource(ctx *core.Context, ioParams *IOParams, params data.Map) (core.Source, error) {
	return f(ctx, ioParams, params)
}
func SourceCreatorFunc(f func(*core.Context, *IOParams, data.Map) (core.Source, error)) SourceCreator {
	return sourceCreatorFunc(f)
}
type SourceCreatorRegistry interface {
	Register(typeName string, c SourceCreator) error
	Lookup(typeName string) (SourceCreator, error)
	List() (map[string]SourceCreator, error)
	Unregister(typeName string) error
}
type defaultSourceCreatorRegistry struct {
	m        sync.RWMutex
	creators map[string]SourceCreator
}
func NewDefaultSourceCreatorRegistry() SourceCreatorRegistry {
	return &defaultSourceCreatorRegistry{
		creators: map[string]SourceCreator{},
	}
}
func (r *defaultSourceCreatorRegistry) Register(typeName string, c SourceCreator) error {
	if err := core.ValidateSymbol(typeName); err != nil {
		return fmt.Errorf("invalid name for source type: %s", err.Error())
	}
	r.m.Lock()
	defer r.m.Unlock()
	lowerName := strings.ToLower(typeName)
	if _, ok := r.creators[lowerName]; ok {
		return fmt.Errorf("source type '%v' is already registered", typeName)
	}
	r.creators[lowerName] = c
	return nil
}
func (r *defaultSourceCreatorRegistry) Lookup(typeName string) (SourceCreator, error) {
	r.m.RLock()
	defer r.m.RUnlock()
	if c, ok := r.creators[strings.ToLower(typeName)]; ok {
		return c, nil
	}
	return nil, core.NotExistError(fmt.Errorf("source type '%v' is not registered", typeName))
}
func (r *defaultSourceCreatorRegistry) List() (map[string]SourceCreator, error) {
	r.m.RLock()
	defer r.m.RUnlock()
	m := make(map[string]SourceCreator, len(r.creators))
	for t, c := range r.creators {
		m[t] = c
	}
	return m, nil
}
func (r *defaultSourceCreatorRegistry) Unregister(typeName string) error {
	r.m.Lock()
	defer r.m.Unlock()
	tn := strings.ToLower(typeName)
	if _, ok := r.creators[tn]; !ok {
		return core.NotExistError(fmt.Errorf("source type '%v' is not registered", typeName))
	}
	delete(r.creators, tn)
	return nil
}
var (
	globalSourceCreatorRegistry = NewDefaultSourceCreatorRegistry()
)
func RegisterGlobalSourceCreator(typeName string, c SourceCreator) error {
	return globalSourceCreatorRegistry.Register(typeName, c)
}
func MustRegisterGlobalSourceCreator(typeName string, c SourceCreator) {
	if err := globalSourceCreatorRegistry.Register(typeName, c); err != nil {
		panic(fmt.Errorf("udf.MustRegisterGlobalSourceCreator: cannot register '%v': %v", typeName, err))
	}
}