package executor

var (
	register = make(map[string]IExecutor)
)

func RegisterFunc(tag string, ex IExecutor) {
	register[tag] = ex
}

func RegisterFuncBatch(b map[string]IExecutor) {
	for k, v := range b {
		register[k] = v
	}
}

func RegisterGetFunc(tag string) (IExecutor, error) {
	ie, ok := register[tag]
	if ok {
		return ie, nil
	}
	return nil, ErrNotExists
}

func UnRegisterFunc(tag string) error {
	if _, ok := register[tag]; !ok {
		return ErrNotExists
	}
	delete(register, tag)
	return nil
}