cloud_task_emulator

package
v0.0.0-...-64d77bc Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunT

func RunT(t *testing.T) *Client

func SetInitialTaskState

func SetInitialTaskState(taskState *tasks.Task, queueName string)

Types

type Queue

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

Queue holds all internals for a task queue

func NewQueue

func NewQueue(name string, state *tasks.Queue, onTaskDone func(task *Task)) (*Queue, *tasks.Queue)

NewQueue creates a new task queue

func (*Queue) Delete

func (queue *Queue) Delete()

Delete stops, purges and removes the queue

func (*Queue) HardReset

func (queue *Queue) HardReset(s *Server)

Goes beyond `Purge` behaviour to synchronously delete all tasks and their name handles

func (*Queue) NewTask

func (queue *Queue) NewTask(newTaskState *tasks.Task) (*Task, *tasks.Task)

NewTask creates a new task on the queue

func (*Queue) Pause

func (queue *Queue) Pause()

Pause pauses the queue

func (*Queue) Purge

func (queue *Queue) Purge() *sync.WaitGroup

Purge purges all tasks from the queue - Normally this is a fire-and-forget operation, but it returns a WaitGroup to allow HardReset to wait for completion

func (*Queue) Resume

func (queue *Queue) Resume()

Resume resumes a paused queue

func (*Queue) Run

func (queue *Queue) Run()

Run starts the queue (workers, token generator and dispatcher)

type Server

type Server struct {
	Options ServerOptions
	// contains filtered or unexported fields
}

Server represents the emulator server

func NewServer

func NewServer() *Server

NewServer creates a new emulator server with its own task and queue bookkeeping

func (*Server) CreateQueue

func (s *Server) CreateQueue(ctx context.Context, in *tasks.CreateQueueRequest) (*tasks.Queue, error)

CreateQueue creates a new queue

func (*Server) CreateTask

func (s *Server) CreateTask(ctx context.Context, in *tasks.CreateTaskRequest) (*tasks.Task, error)

CreateTask creates a new task

func (*Server) DeleteQueue

func (s *Server) DeleteQueue(ctx context.Context, in *tasks.DeleteQueueRequest) (*empty.Empty, error)

DeleteQueue removes an existing queue.

func (*Server) DeleteTask

func (s *Server) DeleteTask(ctx context.Context, in *tasks.DeleteTaskRequest) (*empty.Empty, error)

DeleteTask removes an existing task

func (*Server) GetIamPolicy

func (s *Server) GetIamPolicy(ctx context.Context, in *v1.GetIamPolicyRequest) (*v1.Policy, error)

GetIamPolicy doesn't do anything

func (*Server) GetQueue

func (s *Server) GetQueue(ctx context.Context, in *tasks.GetQueueRequest) (*tasks.Queue, error)

GetQueue returns the requested queue

func (*Server) GetTask

func (s *Server) GetTask(ctx context.Context, in *tasks.GetTaskRequest) (*tasks.Task, error)

GetTask returns the specified task

func (*Server) ListQueues

ListQueues lists the existing queues

func (*Server) ListTasks

ListTasks lists the tasks in the specified queue

func (*Server) PauseQueue

func (s *Server) PauseQueue(ctx context.Context, in *tasks.PauseQueueRequest) (*tasks.Queue, error)

PauseQueue pauses queue execution

func (*Server) PurgeQueue

func (s *Server) PurgeQueue(ctx context.Context, in *tasks.PurgeQueueRequest) (*tasks.Queue, error)

PurgeQueue purges the specified queue

func (*Server) ResumeQueue

func (s *Server) ResumeQueue(ctx context.Context, in *tasks.ResumeQueueRequest) (*tasks.Queue, error)

ResumeQueue resumes a paused queue

func (*Server) RunTask

func (s *Server) RunTask(ctx context.Context, in *tasks.RunTaskRequest) (*tasks.Task, error)

RunTask executes an existing task immediately

func (*Server) SetIamPolicy

func (s *Server) SetIamPolicy(ctx context.Context, in *v1.SetIamPolicyRequest) (*v1.Policy, error)

SetIamPolicy doesn't do anything

func (*Server) TestIamPermissions

TestIamPermissions doesn't do anything

func (*Server) UpdateQueue

func (s *Server) UpdateQueue(ctx context.Context, in *tasks.UpdateQueueRequest) (*tasks.Queue, error)

UpdateQueue updates an existing queue (not implemented yet)

type ServerOptions

type ServerOptions struct {
	HardResetOnPurgeQueue bool
}

type Task

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

Task holds all internals for a task

func NewTask

func NewTask(queue *Queue, taskState *tasks.Task, onDone func(task *Task)) *Task

NewTask creates a new task for the specified queue

func (*Task) Attempt

func (task *Task) Attempt()

Attempt tries to execute a task

func (*Task) Delete

func (task *Task) Delete()

Delete cancels the task if it is queued for execution. This method is called directly by request.

func (*Task) Run

func (task *Task) Run() *tasks.Task

Run runs the task outside of the normal queueing mechanism. This method is called directly by request.

func (*Task) Schedule

func (task *Task) Schedule()

Schedule schedules the task for execution. It is initially called by the queue, later by the task reschedule.

type TaskNameParts

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

Jump to

Keyboard shortcuts

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