q

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCloudTasksQ

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

func NewPubSubQ

func NewPubSubQ(client *pubsub.Client) *pubSubQ

Types

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 to the ClousTasks queue.
	Enqueue(ctx context.Context, task *Task, opts ...CloudTasksOption) (*TaskInfo, error)
}

type Config

type Config interface {
	GetProjectID() string
	GetLocationID() string
	GetBaseUrl() string
	GetServiceAccountEmail() string
}

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 to the Pub/Sub queue.
	Enqueue(ctx context.Context, task *Task, opts ...PubSubOption) (*TaskInfo, 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 []byte, opts ...TaskOption) *Task

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

func NewTaskWithJSON added in v0.12.0

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

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

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
)

Jump to

Keyboard shortcuts

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