q

package
v0.47.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTaskIsNil = fmt.Errorf("task is nil")

Functions

func NewCloudTasksQ

func NewCloudTasksQ(cfg CloudTasksConfig, client *cloudtasks.Client) *cloudTasksQ

func NewPubSubQ

func NewPubSubQ(client *pubsub.Client) *pubSubQ

Types

type CloudTasksConfig added in v0.46.0

type CloudTasksConfig struct {
	ProjectID           string
	LocationID          string
	BaseUrl             string
	ServiceAccountEmail string
}

type CloudTasksOption

type CloudTasksOption interface {
	// String returns a string representation of the option.
	String() string

	// Type describes the type of the option.
	Type() CloudTasksOptionType

	// Value returns a value used to create this option.
	Value() interface{}
}

func ProcessAt

func ProcessAt(t time.Time) CloudTasksOption

ProcessAt returns an option to specify when to process the given task.

type CloudTasksOptionType

type CloudTasksOptionType int
const (
	ProcessAtOpt CloudTasksOptionType = iota
)

type CloudTasksQ

type CloudTasksQ interface {
	// Enqueue enqueues a task with ClousTasks, and returns info.
	EnqueueWithInfo(ctx context.Context, task *Task, opts ...CloudTasksOption) (*TaskInfo, error)
	// Enqueue enqueues a task with ClousTasks.
	Enqueue(ctx context.Context, task *Task, opts ...CloudTasksOption) error
}

type PubSubMessage

type PubSubMessage struct {
	Message struct {
		ID          string            `json:"messageId"`
		PublishTime time.Time         `json:"publishTime"`
		Data        []byte            `json:"data,omitempty"`
		OrderingKey string            `json:"orderingKey,omitempty"`
		Attributes  map[string]string `json:"attributes,omitempty"`
	} `json:"message"`
	Subscription string `json:"subscription"`
}

PubSubMessage is the payload of a Pub/Sub event. See the documentation for more details: https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage

func (*PubSubMessage) GetGroup added in v0.15.0

func (m *PubSubMessage) GetGroup() string

func (*PubSubMessage) GetName added in v0.15.0

func (m *PubSubMessage) GetName() string

func (*PubSubMessage) GetUniqueKey

func (m *PubSubMessage) GetUniqueKey() string

func (*PubSubMessage) UnmarshalData

func (m *PubSubMessage) UnmarshalData(v interface{}) error

type PubSubOption

type PubSubOption interface {
	// String returns a string representation of the option.
	String() string

	// Type describes the type of the option.
	Type() PubSubOptionType

	// Value returns a value used to create this option.
	Value() interface{}
}

func OrderedByTaskName added in v0.13.0

func OrderedByTaskName() PubSubOption

Ordered returns an option to specify the ordered key.

func OrderedKey added in v0.13.0

func OrderedKey(key string) PubSubOption

Ordered returns an option to specify the ordered key.

type PubSubOptionType

type PubSubOptionType int
const (
	OrderedKeyOpt PubSubOptionType = iota
	OrderedByTaskNameOpt
)

type PubSubQ

type PubSubQ interface {
	// Enqueue enqueues a task with Pub/Sub, and returns info.
	EnqueueWithInfo(ctx context.Context, task *Task, opts ...PubSubOption) (*TaskInfo, error)
	// Enqueue enqueues a task with Pub/Sub.
	Enqueue(ctx context.Context, task *Task, opts ...PubSubOption) error
}

type QMessage added in v0.47.0

type QMessage struct {
	Name      string
	Group     string
	UniqueKey string
	Data      []byte
}

func NewQMessage added in v0.47.0

func NewQMessage(req *http.Request) (msg QMessage, err error)

func (*QMessage) UnmarshalData added in v0.47.0

func (m *QMessage) UnmarshalData(v interface{}) error

type Task

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

Task represents a unit of work to be performed.

func NewTask

func NewTask(typename string, payload interface{}, opts ...TaskOption) *Task

NewTask returns a new Task given a type name and payload data that will be marshaled. Options can be passed to configure task processing behavior.

func (Task) GetOptions added in v0.38.0

func (t Task) GetOptions() []TaskOption

func (Task) GetPayload added in v0.38.0

func (t Task) GetPayload() interface{}

func (Task) GetTypename added in v0.38.0

func (t Task) GetTypename() string

type TaskInfo

type TaskInfo struct {
	ID string
}

type TaskOption

type TaskOption interface {
	// String returns a string representation of the option.
	String() string

	// Type describes the type of the option.
	Type() TaskOptionType

	// Value returns a value used to create this option.
	Value() interface{}
}

func Group added in v0.15.0

func Group(key string) TaskOption

Group returns an option to specify the group.

func UniqueKey

func UniqueKey(key string) TaskOption

UniqueKey returns an option to specify the unique key.

type TaskOptionType

type TaskOptionType int
const (
	UniqueKeyOpt TaskOptionType = iota
	GroupOpt
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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