// NewTask initializes and returns a pointer to a new Task instance. It is
// constructed with the given payload, progress, and closer channels
// respectively, all of which should be open when either Succeed(), Fail() or
// Closer() is called.
161102
func NewTask(lifecycle Lifecycle, payload []byte) *Task {
	return &Task{lifecycle: lifecycle, payload: payload}
}
845470
func NewTaskTrackerAPI(spec *loads.Document) *TaskTrackerAPI {
	return &TaskTrackerAPI{
		handlers:              make(map[string]map[string]http.Handler),
		formats:               strfmt.Default,
		defaultConsumes:       "application/json",
		defaultProduces:       "application/json",
		customConsumers:       make(map[string]runtime.Consumer),
		customProducers:       make(map[string]runtime.Producer),
		ServerShutdown:        func() {},
		spec:                  spec,
		ServeError:            errors.ServeError,
		BasicAuthenticator:    security.BasicAuth,
		APIKeyAuthenticator:   security.APIKeyAuth,
		BearerAuthenticator:   security.BearerAuth,
		JSONConsumer:          runtime.JSONConsumer(),
		MultipartformConsumer: runtime.DiscardConsumer,
		JSONProducer:          runtime.JSONProducer(),
		TasksAddCommentToTaskHandler: tasks.AddCommentToTaskHandlerFunc(func(params tasks.AddCommentToTaskParams, principal interface{}) middleware.Responder {
			return middleware.NotImplemented("operation TasksAddCommentToTask has not yet been implemented")
		}),
		TasksCreateTaskHandler: tasks.CreateTaskHandlerFunc(func(params tasks.CreateTaskParams, principal interface{}) middleware.Responder {
			return middleware.NotImplemented("operation TasksCreateTask has not yet been implemented")
		}),
		TasksDeleteTaskHandler: tasks.DeleteTaskHandlerFunc(func(params tasks.DeleteTaskParams, principal interface{}) middleware.Responder {
			return middleware.NotImplemented("operation TasksDeleteTask has not yet been implemented")
		}),
		TasksGetTaskCommentsHandler: tasks.GetTaskCommentsHandlerFunc(func(params tasks.GetTaskCommentsParams) middleware.Responder {
			return middleware.NotImplemented("operation TasksGetTaskComments has not yet been implemented")
		}),
		TasksGetTaskDetailsHandler: tasks.GetTaskDetailsHandlerFunc(func(params tasks.GetTaskDetailsParams) middleware.Responder {
			return middleware.NotImplemented("operation TasksGetTaskDetails has not yet been implemented")
		}),
		TasksListTasksHandler: tasks.ListTasksHandlerFunc(func(params tasks.ListTasksParams) middleware.Responder {
			return middleware.NotImplemented("operation TasksListTasks has not yet been implemented")
		}),
		TasksUpdateTaskHandler: tasks.UpdateTaskHandlerFunc(func(params tasks.UpdateTaskParams, principal interface{}) middleware.Responder {
			return middleware.NotImplemented("operation TasksUpdateTask has not yet been implemented")
		}),
		TasksUploadTaskFileHandler: tasks.UploadTaskFileHandlerFunc(func(params tasks.UploadTaskFileParams, principal interface{}) middleware.Responder {
			return middleware.NotImplemented("operation TasksUploadTaskFile has not yet been implemented")
		}),

		// Applies when the "token" query is set
		APIKeyAuth: func(token string) (interface{}, error) {
			return nil, errors.NotImplemented("api key auth (api_key) token from query param [token] has not yet been implemented")
		},
		// Applies when the "X-Token" header is set
		TokenHeaderAuth: func(token string) (interface{}, error) {
			return nil, errors.NotImplemented("api key auth (token_header) X-Token from header param [X-Token] has not yet been implemented")
		},

		// default authorizer is authorized meaning no requests are blocked
		APIAuthorizer: security.Authorized(),
	}
}
993388
func newTask(s schedule.Schedule, wf *schedulerWorkflow, m *workManager, mm managesMetrics, emitter gomit.Emitter, opts ...core.TaskOption) (*task, error) {

	//Task would always be given a default name.
	//However if a user want to change this name, she can pass optional arguments, in form of core.TaskOption
	//The new name then get over written.

	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,
	}
	//set options
	for _, opt := range opts {
		opt(task)
	}
	return task, nil
}
594825
func NewTaskBackend(b *APIBackend) *TaskBackend {
	return &TaskBackend{
		Logger:                     b.Logger.With(zap.String("handler", "task")),
		TaskService:                b.TaskService,
		AuthorizationService:       b.AuthorizationService,
		OrganizationService:        b.OrganizationService,
		UserResourceMappingService: b.UserResourceMappingService,
		LabelService:               b.LabelService,
		UserService:                b.UserService,
		BucketService:              b.BucketService,
	}
}
201175
func Wrap(task string, err error) Err {
	if err == nil {
		return nil
	}

	return NewError(task, err)
}
1135245
func newTray(o *TrayOptions, c *asticontext.Canceller, d *dispatcher, i *identifier, wrt *writer) (t *Tray) {
	// Init
	t = &Tray{
		o:      o,
		object: newObject(nil, c, d, i, wrt, i.new()),
	}

	// Make sure the tray's context is cancelled once the destroyed event is received
	t.On(EventNameTrayEventDestroyed, func(e Event) (deleteListener bool) {
		t.cancel()
		return true
	})
	return
}
449502
func (remote *RemoteDebugger) NewTab(url string) (*Tab, error) {
	path := "/json/new"
	if url != "" {
		path += "?" + url
	}

	resp, err := responseError(remote.http.Do(remote.http.Request("GET", path, nil, nil)))
	if err != nil {
		return nil, err
	}

	var tab Tab
	if err = decode(resp, &tab); err != nil {
		return nil, err
	}

	if err = remote.connectWs(&tab); err != nil {
		return nil, err
	}

	return &tab, nil
}
1132687
func UpdateTask(tx Tx, t *api.Task) error {
	return tx.update(tableTask, t)
}
318478
func CreateTask(tx Tx, t *api.Task) error {
	return tx.create(tableTask, t)
}
174880
func (a *Astilectron) NewTray(o *TrayOptions) *Tray {
	return newTray(o, a.canceller, a.dispatcher, a.identifier, a.writer)
}
649201
func NewTarget(st *state.State, logFile io.Writer, errorLog Logger) raftlease.NotifyTarget {
	return st.LeaseNotifyTarget(logFile, errorLog)
}
1366453
func NewTooManyRequests(message string, retryAfterSeconds int) *StatusError {
	return &StatusError{metav1.Status{
		Status:  metav1.StatusFailure,
		Code:    http.StatusTooManyRequests,
		Reason:  metav1.StatusReasonTooManyRequests,
		Message: message,
		Details: &metav1.StatusDetails{
			RetryAfterSeconds: int32(retryAfterSeconds),
		},
	}}
}
1059412
func (*NewGoroutineDispatcher) DispatchTask(task *swf.PollForDecisionTaskOutput, handler func(*swf.PollForDecisionTaskOutput)) {
	go handler(task)
}
1197768
func newTPUService(client *http.Client) (*tpuService, error) {
	s, err := tpuapi.New(client)
	if err != nil {
		return nil, err
	}
	return &tpuService{
		projects: tpuapi.NewProjectsService(s),
	}, nil
}
247658
func NewTask(name, driver string) *Task {
	return &Task{
		Name:   name,
		Driver: driver,
	}
}
798934
func NewTask(taskName string, parameters map[string]string) *automationpb.Task {
	return &automationpb.Task{
		State:      automationpb.TaskState_NOT_STARTED,
		Name:       taskName,
		Parameters: parameters,
	}
}
779892
func (auto *AutoGcd) NewTab() (*Tab, error) {
	target, err := auto.debugger.NewTab()
	if err != nil {
		return nil, &InvalidTabErr{Message: "unable to create tab: " + err.Error()}
	}
	auto.tabLock.Lock()
	defer auto.tabLock.Unlock()

	tab, err := open(target)
	if err != nil {
		return nil, err
	}
	auto.tabs[target.Target.Id] = tab
	return tab, nil
}