scheduler

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2022 License: MIT Imports: 18 Imported by: 2

README

scheduler

Go Reference Test

Scheduler manages scheduled tasks using CloudTasks.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTaskValidation    = errors.New("task validation error")
	ErrTaskAlreadyExists = errors.New("task already exists")
)
View Source
var ErrInvalidTask = errors.New("invalid task")
View Source
var ErrInvalidTaskName = errors.New("invalid task name")

Functions

func ParseTaskName

func ParseTaskName(prefix, taskName string) (string, int, error)

func QueuePath

func QueuePath(projectID, location, queue string) string

func TaskToPbTask

func TaskToPbTask(task *Task) (*taskspb.Task, error)

Types

type CloudTasksClient

type CloudTasksClient interface {
	ListTasks(ctx context.Context, req *taskspb.ListTasksRequest, opts ...gax.CallOption) *cloudtasks.TaskIterator
	CreateTask(ctx context.Context, req *taskspb.CreateTaskRequest, opts ...gax.CallOption) (*taskspb.Task, error)
	DeleteTask(ctx context.Context, req *taskspb.DeleteTaskRequest, opts ...gax.CallOption) error
}

type Iterator

type Iterator struct {
	// contains filtered or unexported fields
}

func NewIterator

func NewIterator(t TaskLister, queuePath, prefix string, opts ...gax.CallOption) *Iterator

func (*Iterator) Next

func (i *Iterator) Next(ctx context.Context) (*Task, error)

type OAuthToken

type OAuthToken struct {
	ServiceAccountEmail string
	Scope               string
}

type OIDCToken

type OIDCToken struct {
	ServiceAccountEmail string
	Audience            string
}

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

func New

func New(client CloudTasksClient, projectID, location, queue, prefix string) *Scheduler

func (*Scheduler) Create

func (s *Scheduler) Create(ctx context.Context, task *Task, opts ...gax.CallOption) error

func (*Scheduler) Delete

func (s *Scheduler) Delete(ctx context.Context, taskName string, opts ...gax.CallOption) error

func (*Scheduler) List

func (s *Scheduler) List(opts ...gax.CallOption) *Iterator

func (*Scheduler) Sync

func (s *Scheduler) Sync(ctx context.Context, tasks []*Task, opts ...gax.CallOption) error

type Task

type Task struct {
	QueuePath     string
	Prefix        string
	ID            string
	ScheduledAt   time.Time
	Request       *http.Request
	Authorization isAuthorizationToken
	Version       int
}

func PbTaskToTask

func PbTaskToTask(ctx context.Context, queuePath, taskIDPrefix string, pb *taskspb.Task) (*Task, error)

func (*Task) Compare

func (t *Task) Compare(target *Task) bool

func (*Task) TaskID

func (t *Task) TaskID() string

func (*Task) TaskName

func (t *Task) TaskName() string

func (*Task) Validate

func (t *Task) Validate() error

type TaskIterator

type TaskIterator interface {
	Next() (*taskspb.Task, error)
	PageInfo() *iterator.PageInfo
}

type TaskLister

type TaskLister interface {
	ListTasks(ctx context.Context, req *taskspb.ListTasksRequest, opts ...gax.CallOption) TaskIterator
}

type TaskListerFunc

type TaskListerFunc func(ctx context.Context, req *taskspb.ListTasksRequest, opts ...gax.CallOption) *cloudtasks.TaskIterator

func (TaskListerFunc) ListTasks

func (f TaskListerFunc) ListTasks(ctx context.Context, req *taskspb.ListTasksRequest, opts ...gax.CallOption) TaskIterator

Directories

Path Synopsis
example module
Package mock_scheduler is a generated GoMock package.
Package mock_scheduler is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL