// New: Creates a new task. The task will be enqueued in the tasks list
// and will be executed at the earliest opportunity by a bot that has at
// least the dimensions as described in the task request.
553407
func (r *TasksService) New(swarmingrpcsnewtaskrequest *SwarmingRpcsNewTaskRequest) *TasksNewCall {
	c := &TasksNewCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.swarmingrpcsnewtaskrequest = swarmingrpcsnewtaskrequest
	return c
}
908375
func (client *Client) CreateApplicationTask(appGUID string, task Task) (Task, Warnings, error) {
	bodyBytes, err := json.Marshal(task)
	if err != nil {
		return Task{}, nil, err
	}

	request, err := client.newHTTPRequest(requestOptions{
		RequestName: internal.PostApplicationTasksRequest,
		URIParams: internal.Params{
			"app_guid": appGUID,
		},
		Body: bytes.NewReader(bodyBytes),
	})
	if err != nil {
		return Task{}, nil, err
	}

	var responseTask Task
	response := cloudcontroller.Response{
		DecodeJSONResponseInto: &responseTask,
	}

	err = client.connection.Make(request, &response)
	return responseTask, response.Warnings, err
}
90190
func NewCreate(ctx *Context, stmt *rel.SqlCreate) *Create {
	return &Create{Stmt: stmt, PlanBase: NewPlanBase(false), Ctx: ctx}
}
1321937
func New(ctx context.Context, ds models.Datastore, mq models.MessageQueue, apiURL string, opts ...ServerOption) *Server {
	metricLogger := runner.NewMetricLogger()
	funcLogger := runner.NewFuncLogger()

	rnr, err := runner.New(ctx, funcLogger, metricLogger)
	if err != nil {
		logrus.WithError(err).Fatalln("Failed to create a runner")
		return nil
	}

	tasks := make(chan task.Request)
	s := &Server{
		Runner:    rnr,
		Router:    gin.New(),
		Datastore: ds,
		MQ:        mq,
		hotroutes: routecache.New(cacheSize),
		tasks:     tasks,
		Enqueue:   DefaultEnqueue,
		apiURL:    apiURL,
	}

	s.Router.Use(prepareMiddleware(ctx))
	s.bindHandlers(ctx)
	s.setupMiddlewares()

	for _, opt := range opts {
		opt(s)
	}
	return s
}
502934
func NewCreateTask(ctx *middleware.Context, handler CreateTaskHandler) *CreateTask {
	return &CreateTask{Context: ctx, Handler: handler}
}
73204
func (m *JobExecutor) WalkCreate(p *plan.Create) (Task, error) {
	root := m.NewTask(p)
	return root, root.Add(NewCreate(m.Ctx, p))
}
966091
func New(token string) (*Bot, error) {
	bot := Bot{
		Token: token,
	}

	return bot.Handshake()
}
1142137
func New(processor func(Job), jobBufsize int, maxIdle, maxActive uint64) *Pool {
	p := &Pool{
		processor: processor,
		jobs:      make(chan Job, jobBufsize),
		maxIdle:   maxIdle,
		maxActive: maxActive,
	}
	return p
}
1312120
func NewListTasksParams() *ListTasksParams {
	var (
		pageSizeDefault = int32(20)
	)
	return &ListTasksParams{
		PageSize: &pageSizeDefault,

		timeout: cr.DefaultTimeout,
	}
}
164987
func New(interval time.Duration) (*Batcher, error) {
	watcher, err := fsnotify.NewWatcher()

	batcher := &Batcher{}
	batcher.Watcher = watcher
	batcher.interval = interval
	batcher.done = make(chan struct{}, 1)
	batcher.Events = make(chan []fsnotify.Event, 1)

	if err == nil {
		go batcher.run()
	}

	return batcher, err
}
183414
func New(ctx context.Context, store storage.Store, stm *semantic.Statement, chanSize, bulkSize int, w io.Writer) (Executor, error) {
	switch stm.Type() {
	case semantic.Query:
		return newQueryPlan(ctx, store, stm, chanSize, w)
	case semantic.Insert:
		return &insertPlan{
			stm:    stm,
			store:  store,
			tracer: w,
		}, nil
	case semantic.Delete:
		return &deletePlan{
			stm:    stm,
			store:  store,
			tracer: w,
		}, nil
	case semantic.Create:
		return &createPlan{
			stm:    stm,
			store:  store,
			tracer: w,
		}, nil
	case semantic.Drop:
		return &dropPlan{
			stm:    stm,
			store:  store,
			tracer: w,
		}, nil
	case semantic.Construct:
		qp, _ := newQueryPlan(ctx, store, stm, chanSize, w)
		return &constructPlan{
			stm:       stm,
			store:     store,
			tracer:    w,
			bulkSize:  bulkSize,
			queryPlan: qp,
			construct: true,
		}, nil
	case semantic.Deconstruct:
		qp, _ := newQueryPlan(ctx, store, stm, chanSize, w)
		return &constructPlan{
			stm:       stm,
			store:     store,
			tracer:    w,
			bulkSize:  bulkSize,
			queryPlan: qp,
			construct: false,
		}, nil
	case semantic.Show:
		return &showPlan{
			stm:    stm,
			store:  store,
			tracer: w,
		}, nil
	default:
		return nil, fmt.Errorf("planner.New: unknown statement type in statement %v", stm)
	}
}
1618
func NewListTask(msg string) *ListTask {
	return &ListTask{
		msg: msg,
		ch:  make(chan *Update, 1),
	}
}
1256222
func New(o *data.Operation, i data.Input, x interface{}) (*Request, error) {
	input := reflect.ValueOf(i)
	if input.IsValid() && input.Elem().IsValid() {
		err := i.Validate()
		if err != nil {
			return nil, err
		}
	}
	output := reflect.ValueOf(x)

	return &Request{
		Operation: o,
		Input:     &input,
		Output:    &output,
	}, nil
}
1089217
func NewRetryTaskState(signature *Signature) *TaskState {
	return &TaskState{
		TaskUUID: signature.UUID,
		State:    StateRetry,
	}
}
110610
func (api *InfraHostsAPI) Create(hostSpec *HostCreateSpec) (task *Task, err error) {
	body, err := json.Marshal(hostSpec)
	if err != nil {
		return
	}
	res, err := api.client.restClient.Post(
		api.client.Endpoint+InfraHostsUrl,
		"application/json",
		bytes.NewReader(body),
		api.client.options.TokenOptions)
	if err != nil {
		return
	}
	defer res.Body.Close()
	task, err = getTask(getError(res))
	return
}
832861
func NewListTasks(ctx *middleware.Context, handler ListTasksHandler) *ListTasks {
	return &ListTasks{Context: ctx, Handler: handler}
}
633464
func (s *Service) CreateTask(ctx context.Context, tc influxdb.TaskCreate) (*influxdb.Task, error) {
	var t *influxdb.Task
	err := s.kv.Update(ctx, func(tx Tx) error {
		task, err := s.createTask(ctx, tx, tc)
		if err != nil {
			return err
		}
		t = task
		return nil
	})
	if err != nil {
		return nil, err
	}

	return t, nil
}