tasks

package
v0.4.32 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2021 License: MPL-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	TaskStateNew      = TaskState("NEW")
	TaskStateRunning  = TaskState("RUNNING")
	TaskStateFinished = TaskState("FINISHED")
	TaskStateError    = TaskState("ERROR")
)

Variables

This section is empty.

Functions

func ExtractTasksInto

func ExtractTasksInto(r pagination.Page, v interface{}) error

func List

List returns a Pager which allows you to iterate over a collection of cluster templates. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.

func WaitForStatus

func WaitForStatus(client *gcorecloud.ServiceClient, id string, status TaskState, secs int, stopOnTaskError bool) error

WaitForStatus will continually poll the task resource, checking for a particular status. It will do this for the amount of seconds defined.

func WaitTaskAndProcessResult

func WaitTaskAndProcessResult(
	client *gcorecloud.ServiceClient, task TaskID, stopOnTaskError bool, waitSeconds int, taskProcessor CheckTaskResult) error

WaitTaskAndProcessResult periodically check status state and invoke taskProcessor when when task is finished

func WaitTaskAndReturnResult

func WaitTaskAndReturnResult(
	client *gcorecloud.ServiceClient, task TaskID, stopOnTaskError bool,
	waitSeconds int, taskProcessor RetrieveTaskResult) (interface{}, error)

WaitTaskAndReturnResult periodically check status state and return changed object when task is finished

Types

type CheckTaskResult

type CheckTaskResult func(task TaskID) error

type CreateResult

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

CreateResult represents the result of a create operation. Call its Extract method to interpret it as a Network.

func (CreateResult) Extract

func (r CreateResult) Extract() (*Task, error)

Extract is a function that accepts a result and extracts a task resource.

func (CreateResult) ExtractInto

func (r CreateResult) ExtractInto(v interface{}) error

type DeleteResult

type DeleteResult struct {
	gcorecloud.ErrResult
}

DeleteResult represents the result of a delete operation. Call its ExtractErr method to determine if the request succeeded or failed.

type GetResult

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

GetResult represents the result of a get operation. Call its Extract method to interpret it as a Network.

func Get

func Get(c *gcorecloud.ServiceClient, id string) (r GetResult)

Get retrieves a specific cluster template based on its unique ID.

func (GetResult) Extract

func (r GetResult) Extract() (*Task, error)

Extract is a function that accepts a result and extracts a task resource.

func (GetResult) ExtractInto

func (r GetResult) ExtractInto(v interface{}) error

type Result

type Result struct {
	gcorecloud.Result
}

Result represents the operation result that returns tasks

func (Result) Extract

func (r Result) Extract() (*TaskResults, error)

Extract is a function that accepts a result and extracts a task resource.

type RetrieveTaskResult

type RetrieveTaskResult func(task TaskID) (interface{}, error)

type Task

type Task struct {
	ID               string                     `json:"id"`
	TaskType         string                     `json:"task_type"`
	ProjectID        int                        `json:"project_id,omitempty"`
	ClientID         int                        `json:"client_id"`
	RegionID         *int                       `json:"region_id"`
	UserID           int                        `json:"user_id"`
	UserClientID     int                        `json:"user_client_id"`
	State            TaskState                  `json:"state"`
	CreatedOn        gcorecloud.JSONRFC3339NoZ  `json:"created_on"`
	UpdatedOn        *gcorecloud.JSONRFC3339NoZ `json:"updated_on"`
	FinishedOn       *gcorecloud.JSONRFC3339NoZ `json:"finished_on"`
	AcknowledgedAt   *gcorecloud.JSONRFC3339NoZ `json:"acknowledged_at"`
	AcknowledgedBy   *int                       `json:"acknowledged_by"`
	CreatedResources *map[string]interface{}    `json:"created_resources"`
	RequestID        *string                    `json:"request_id"`
	Error            *string                    `json:"error"`
	Data             *map[string]interface{}    `json:"data"`
}

type TaskID

type TaskID string

type TaskPage

type TaskPage struct {
	pagination.LinkedPageBase
}

ClusterPage is the page returned by a pager when traversing over a collection of tasks.

func (TaskPage) IsEmpty

func (r TaskPage) IsEmpty() (bool, error)

IsEmpty checks whether a ClusterPage struct is empty.

func (TaskPage) NextPageURL

func (r TaskPage) NextPageURL() (string, error)

NextPageURL is invoked when a paginated collection of cluster has reached the end of a page and the pager seeks to traverse over a new one. In order to do this, it needs to construct the next page's URL.

type TaskResults

type TaskResults struct {
	Tasks []TaskID `json:"tasks"`
}

type TaskState

type TaskState string

type Tasks

type Tasks []Task

func ExtractTasks

func ExtractTasks(r pagination.Page) (Tasks, error)

ExtractTasks accepts a Page struct, specifically a ClusterPage struct, and extracts the elements into a slice of Task structs. In other words, a generic collection is mapped into a relevant slice.

type UpdateResult

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

UpdateResult represents the result of an update operation. Call its Extract method to interpret it as a Network.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Task, error)

Extract is a function that accepts a result and extracts a task resource.

func (UpdateResult) ExtractInto

func (r UpdateResult) ExtractInto(v interface{}) error

Directories

Path Synopsis
tasks unit tests
tasks unit tests

Jump to

Keyboard shortcuts

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