delay

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2018 License: MIT Imports: 21 Imported by: 0

README

delay

GoDoc Build Status

Altipla Queues Go SDK.

Install
go get github.com/altipla-consulting/delay
Contributing

You can make pull requests or create issues in GitHub. Any code you send should be formatted using gofmt.

Running tests

Run the tests

make test
License

MIT License

Documentation

Overview

Package delay implements a Altipla Queues Go SDK to send tasks and listen to them later to run them in a distributed background process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

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

Conn represents a connection to the queues server.

func NewConn

func NewConn(project, clientID, clientSecret string) (*Conn, error)

NewConn opens a new connection to a queues server. It needs the project and the OAuth client credentials to authenticate the requests.

func NewDebugConn added in v1.1.0

func NewDebugConn() (*Conn, error)

NewDebugConn creates a new local debugging connection that uses a direct Redis queue to simulate the queue. The downside is both the sender and receiver should be connected at the same time to send the message; there is no storage.

type Function

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

Function is a stored task implementation.

func Func

func Func(key string, i interface{}) *Function

Func builds and registers a new task implementation.

func (*Function) Call

func (f *Function) Call(ctx context.Context, queue QueueSpec, args ...interface{}) error

Call builds a task invocation and directly sends it individually to the queue.

If you are going to send multiple tasks at the same time is more efficient to build all of them with Task() first and then send them in batches with queue.SendTasks(). If sending a single task this function will be similar in performance to the batch method described before.

func (*Function) Task

func (f *Function) Task(args ...interface{}) (*pb.SendTask, error)

Task builds a task invocation to the function. You can later send the task in batches using queue.SendTasks() or directly invoke Call() to make both things at the same time.

type Listener

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

Listener is a background goroutine that handles messages from the queues and run them in other controlled goroutines.

func NewListener

func NewListener(sentryDSN string) *Listener

NewListener prepares a new background goroutine to handle messages.

func (*Listener) Handle

func (lis *Listener) Handle(queue QueueSpec)

Handle opens a listen connection to the queue and starts receiving tasks from it in the background.

type QueueSpec

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

QueueSpec contains a reference to a queue to send to and receive tasks from that queue.

func Queue

func Queue(conn *Conn, name string) QueueSpec

Queue builds a new QueueSpec reference to a queue.

func (QueueSpec) SendTasks

func (queue QueueSpec) SendTasks(ctx context.Context, tasks []*pb.SendTask) error

SendTasks sends a list of tasks in batch to a queue.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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