func (t *TaskType) GetFirstHandlerState() TaskState {
	return t.firstHandlerState
}
GetFirstHandlerState gets the first handler state
package task
import (
	"errors"
	"reflect"
)
var (
	DoneTaskState  TaskState = "done"
	ErrorTaskState TaskState = "error"
	TaskTypeDoesNotExistErr    = errors.New("task type does not exist")
	TaskHandlerDoesNotExistErr = errors.New("task handler does not exist")
	taskTypes = make(map[string]*TaskType)
)
func RegisterTaskType(taskType string) *TaskType {
	taskTypes[taskType] = &TaskType{
		handlers: make(TaskReflectMap),
	}
	return taskTypes[taskType]
}
func DoesTaskTypeExist(taskType string) bool {
	_, ok := taskTypes[taskType]
	return ok
}
func GetTaskType(taskType string) (*TaskType, error) {
	if !DoesTaskTypeExist(taskType) {
		return &TaskType{}, TaskTypeDoesNotExistErr
	}
	return taskTypes[taskType], nil
}
func (t *TaskType) HasHandlers() bool {
	return len(t.handlers) > 0
}
func (t *TaskType) addHandler(handlerName TaskState, handler interface{}) {
	t.handlers[string(handlerName)] = reflect.ValueOf(handler)
}
func (t *TaskType) AddHandlers(handlers TaskHandlerMap) {
	for handlerName, handler := range handlers {
		if t.internalType == nil {
			handleTypes := reflect.TypeOf(handler)
			handleType := handleTypes.In(1)
			t.internalType = handleType
		}
		t.addHandler(handlerName, handler)
	}
}
func (t *TaskType) GetHandler(handlerName TaskState) (reflect.Value, error) {
	handler, ok := t.handlers[string(handlerName)]
	if !ok {
		return reflect.Value{}, TaskHandlerDoesNotExistErr
	}
	return handler, nil
}