func (t *task) CreationTime() *time.Time {
	return &t.creationTime
}
CreateTime returns the time the task was created.
package scheduler
import (
	"errors"
	"fmt"
	"net"
	"strconv"
	"sync"
	"time"
	"github.com/intelsdi-x/gomit"
	"github.com/pborman/uuid"
	log "github.com/sirupsen/logrus"
	"github.com/intelsdi-x/snap/core"
	"github.com/intelsdi-x/snap/core/scheduler_event"
	"github.com/intelsdi-x/snap/core/serror"
	"github.com/intelsdi-x/snap/grpc/controlproxy"
	"github.com/intelsdi-x/snap/pkg/schedule"
	"github.com/intelsdi-x/snap/scheduler/wmap"
)
const (
	DefaultDeadlineDuration = time.Second * 5
	DefaultStopOnFailure = 10
)
var (
	taskLogger = schedulerLogger.WithField("_module", "scheduler-task")
	ErrTaskNotFound = errors.New("Task not found")
	ErrTaskNotStopped = errors.New("Task must be stopped")
	ErrTaskHasAlreadyBeenAdded = errors.New("Task has already been added")
	ErrTaskDisabledOnFailures = errors.New("Task disabled due to consecutive failures")
	ErrTaskNotDisabled = errors.New("Task must be disabled")
)
type task struct {
	sync.Mutex  
	id                 string
	name               string
	schResponseChan    chan schedule.Response
	killChan           chan struct{}
	schedule           schedule.Schedule
	workflow           *schedulerWorkflow
	state              core.TaskState
	creationTime       time.Time
	lastFireTime       time.Time
	manager            managesWork
	metricsManager     managesMetrics
	deadlineDuration   time.Duration
	hitCount           uint
	missedIntervals    uint
	failureMutex       sync.Mutex
	failedRuns         uint
	lastFailureMessage string
	lastFailureTime    time.Time
	stopOnFailure      int
	eventEmitter       gomit.Emitter
	RemoteManagers     managers
	isStream           bool
	maxCollectDuration time.Duration
	maxMetricsBuffer   int64
}
func newTask(s schedule.Schedule, wf *schedulerWorkflow, m *workManager, mm managesMetrics, emitter gomit.Emitter, opts ...core.TaskOption) (*task, error) {
	taskID := uuid.New()
	name := fmt.Sprintf("Task-%s", taskID)
	wf.eventEmitter = emitter
	mgrs := newManagers(mm)
	err := createTaskClients(&mgrs, wf)
	if err != nil {
		return nil, err
	}
	_, stream := s.(*schedule.StreamingSchedule)
	task := &task{
		id:               taskID,
		name:             name,
		schResponseChan:  make(chan schedule.Response),
		schedule:         s,
		state:            core.TaskStopped,
		creationTime:     time.Now(),
		workflow:         wf,
		manager:          m,
		metricsManager:   mm,
		deadlineDuration: DefaultDeadlineDuration,
		stopOnFailure:    DefaultStopOnFailure,
		eventEmitter:     emitter,
		RemoteManagers:   mgrs,
		isStream:         stream,
	}
	for _, opt := range opts {
		opt(task)
	}
	return task, nil
}
func (t *task) Option(opts ...core.TaskOption) core.TaskOption {
	var previous core.TaskOption
	for _, opt := range opts {
		previous = opt(t)
	}
	return previous
}
func (t *task) MaxCollectDuration() time.Duration {
	return t.maxCollectDuration
}
func (t *task) SetMaxCollectDuration(ti time.Duration) {
	t.maxCollectDuration = ti
}
func (t *task) MaxMetricsBuffer() int64 {
	return t.maxMetricsBuffer
}
func (t *task) SetMaxMetricsBuffer(i int64) {
	t.maxMetricsBuffer = i
}
func (t *task) GetName() string {
	return t.name
}
func (t *task) SetName(name string) {
	t.name = name
}