clients

package
v0.0.0-...-3ed64e7 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandQueueName

func RandQueueName() string

RandQueueName returns a random string to use as a queue name. Used for testing in a few places

Types

type Client

type Client struct {
	ID       string
	Queues   []string
	Conn     ClientConn
	NotifyCh chan string
}

Client represents a single okq client, either one just submitting events or a consumer. It expects to be handled in a single threaded context, except for methods marked otherwise (specifically Notify and DrainNotifyCh)

func NewClient

func NewClient(conn ClientConn) *Client

NewClient creates a new Client structure around the given ClientConn

func (*Client) Close

func (client *Client) Close()

Close closes the client's connection

func (*Client) DrainNotifyCh

func (client *Client) DrainNotifyCh()

DrainNotifyCh removes any queue notifications that may be buffered in the client. This may be called from another thread besides the one which "owns" the client

func (*Client) Notify

func (client *Client) Notify(queueName string)

Notify notifies the client that queueName has an event on it. This may be called from another thread besides the one which "owns" the client

func (*Client) Sprintf

func (client *Client) Sprintf(format string, args ...interface{}) error

Sprintf returns the given formatted string with a little extra info about the client prepended to it

type ClientConn

type ClientConn interface {
	io.ReadWriteCloser
	RemoteAddr() net.Addr
}

ClientConn is obstensibly a net.Conn, but for testing we don't want to have to set up a real listen socket and all that noise

type FakeClientConn

type FakeClientConn struct {
	*bytes.Buffer
}

FakeClientConn implements ClientConn, but isn't an actual network connection. Can still be passed into resp.ReadMessage and other things that take in io.Readers and io.Writers. Used for testing here and other places

func NewFakeClientConn

func NewFakeClientConn() *FakeClientConn

NewFakeClientConn initializes a FakeClientConn and returns it

func (*FakeClientConn) Close

func (fconn *FakeClientConn) Close() error

Close does nothing and always returns nil. It is only here to implement the ClientConn interface

func (*FakeClientConn) RemoteAddr

func (fconn *FakeClientConn) RemoteAddr() net.Addr

RemoteAddr always returns nil. It is only here to implement the ClientConn interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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