go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/gae/service/taskqueue/raw_interface.go (about)

     1  // Copyright 2015 The LUCI Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package taskqueue
    16  
    17  import "time"
    18  
    19  // RawCB is a simple callback for RawInterface.DeleteMulti, getting the error
    20  // for the attempted deletion.
    21  type RawCB func(index int, err error)
    22  
    23  // RawTaskCB is the callback for RawInterface.AddMulti, getting the added task
    24  // and an error.
    25  type RawTaskCB func(*Task, error)
    26  
    27  // RawStatsCB is the callback for RawInterface.Stats. It takes the statistics
    28  // object, as well as an error (e.g. in case the queue doesn't exist).
    29  type RawStatsCB func(*Statistics, error)
    30  
    31  // Constraints is the set of implementation-specific task queue constraints.
    32  type Constraints struct {
    33  	// MaxAddSize is the maximum number of tasks that can be added to a queue in
    34  	// a single Add call.
    35  	MaxAddSize int
    36  	// MaxDeleteSize is the maximum number of tasks that can be deleted from
    37  	// a queue in a single Delete call.
    38  	MaxDeleteSize int
    39  }
    40  
    41  // RawInterface is the full interface to the Task Queue service.
    42  type RawInterface interface {
    43  	// AddMulti adds multiple tasks to the given queue, calling cb for each item.
    44  	//
    45  	// The task passed to the callback function will have all the default values
    46  	// filled in, and will have the Name field populated, if the input task was
    47  	// anonymous (e.g. the Name field was blank).
    48  	AddMulti(tasks []*Task, queueName string, cb RawTaskCB) error
    49  	DeleteMulti(tasks []*Task, queueName string, cb RawCB) error
    50  
    51  	Lease(maxTasks int, queueName string, leaseTime time.Duration) ([]*Task, error)
    52  	LeaseByTag(maxTasks int, queueName string, leaseTime time.Duration, tag string) ([]*Task, error)
    53  	ModifyLease(task *Task, queueName string, leaseTime time.Duration) error
    54  
    55  	Purge(queueName string) error
    56  
    57  	Stats(queueNames []string, cb RawStatsCB) error
    58  
    59  	Constraints() Constraints
    60  
    61  	GetTestable() Testable
    62  }