client

package
v0.0.0-...-d1ab4a3 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2015 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidResType returned when the response type sent by the server is
	// invalid.
	ErrInvalidResType = errors.New("taskq client: invalid response type")
	// ErrRequestNotFound returned when the request id is not found.
	ErrRequestNotFound = errors.New("taskq client: request not found")
	// ErrInvalidResponse returned when the server response is invalid.
	ErrInvalidResponse = errors.New("taskq client: invalid response")
)

Functions

This section is empty.

Types

type Call

type Call chan Response

Call represents one asynchronous request enqued by the client. Once the response is received, the client will send it over this channel.

type Client

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Client represents a client to a taskq server.

func New

func New(addr string) (client *Client, err error)

New creates a client to the given address.

func (*Client) Ack

func (c *Client) Ack(ctx context.Context, queue string, task server.TaskID) (
	err error)

Ack acknowledges a task in the queue.

func (*Client) Close

func (c *Client) Close()

Close closes the client and its underlying connection. All pending calls will be returned with an error.

func (*Client) DeQ

func (c *Client) DeQ(ctx context.Context, queue string) (task server.Task,
	err error)

DeQ dequeues a task from the given queue. It returns the task or an error.

func (*Client) EnQ

func (c *Client) EnQ(ctx context.Context, queue string, body []byte) (
	id server.TaskID, err error)

EnQ enqueues a task with the given body in the queue. It returns the task's id or an error.

func (*Client) GoAck

func (c *Client) GoAck(queue string, taskID server.TaskID, call Call) (
	server.ReqID, Call)

GoAck acknowledges a task in the given queue. This method returns the request ID and the Call represeting the enque.

If call is nil in the arguments, this method returns a new call. Otherwise it reuses and returns the provided call.

func (*Client) GoDeQ

func (c *Client) GoDeQ(queue string, call Call) (server.ReqID, Call)

GoDeQ dequeues a task from the given queue. This method returns the request ID and the Call represeting the enque.

If call is nil in the arguments, this method returns a new call. Otherwise it reuses and returns the provided call.

func (*Client) GoEnQ

func (c *Client) GoEnQ(queue string, body []byte, call Call) (
	server.ReqID, Call)

GoEnQ enques a task with the given body in the given queue. This method returns the request ID and the Call represeting the enque.

If call is nil in the arguments, this method returns a new call. Otherwise it reuses and returns the provided call.

type Response

type Response struct {
	ID    server.ReqID // ID is the request ID.
	Data  interface{}  // Data is the response data returned by the server.
	Error error        // Error is the response error.
}

Response represents a response to a request.

Jump to

Keyboard shortcuts

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