queued

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 31 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultTCPPort = 12361
	DefaultWSPort  = 80
)

The default ports that the queued server listens on.

Variables

View Source
var (
	ErrNilClient = errors.New("uninitialised client")
	ErrClosed    = errors.New("client is closed")
)

errors

View Source
var ErrNilConfiguration = errors.New("illegal nil configuration data")

ErrNilConfiguration is returned when a ClientConfig fails to validate.

Functions

func AreEqual

func AreEqual(c *ClientConfig, d *ClientConfig) bool

AreEqual returns true iff the two configurations are equal.

Types

type Client

type Client struct {
	log.BasicLogable
	io.Closer
	// contains filtered or unexported fields
}

Client is the client view of the server.

func NewClient

func NewClient(ctx context.Context, cfg *ClientConfig) (*Client, error)

NewClient returns a new client view of the server specified by the configuration cfg.

func (*Client) Acknowledge

func (c *Client) Acknowledge(ctx context.Context, id driver.ID) error

Acknowledge removes the message with the given ID from its queue.

func (*Client) Close

func (c *Client) Close() error

Close closes the client.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, name string) error

Delete deletes the queue with the given name.

func (*Client) DriverName

func (c *Client) DriverName() string

DriverName returns "pcas queued client".

func (*Client) Get

func (c *Client) Get(ctx context.Context, name string) (driver.ID, []byte, time.Time, error)

Get returns the ID, content, and expiry time of the next message from the queue with the given name. The message will, eventually, be automatically requeued if it is not acknowledged.

func (*Client) Len

func (c *Client) Len(ctx context.Context, name string) (int, error)

Len returns the number of messages in the queue with the given name that are not awaiting acknowledgement.

func (*Client) Put

func (c *Client) Put(ctx context.Context, name string, content []byte) error

Put places a message with the given content on the queue with the given name.

func (*Client) Refresh

func (c *Client) Refresh(ctx context.Context, id driver.ID) (time.Time, error)

Refresh gets a new expiry time for the message with the given ID.

func (*Client) Requeue

func (c *Client) Requeue(ctx context.Context, id driver.ID) error

Requeue requeues the message with the given ID.

type ClientConfig

type ClientConfig struct {
	Address     *address.Address // The address to connect to
	SSLCert     []byte           // The SSL certificate(s) (if any)
	SSLDisabled bool             // Disable SSL?
}

ClientConfig describes the configuration options we allow a user to set on a queue client.

func DefaultConfig

func DefaultConfig() *ClientConfig

DefaultConfig returns a new client configuration initialised with the default values.

The initial default value for the hostname will be read from the environment variable PCAS_QUEUE_ADDRESS on package init. This should take the form "hostname[:port]" or "ws://host/path".

func SetDefaultConfig

func SetDefaultConfig(c *ClientConfig) *ClientConfig

SetDefaultConfig sets the default client configuration to c and returns the old default configuration. This change will be reflected in future calls to DefaultClientConfig.

func (*ClientConfig) Copy

func (c *ClientConfig) Copy() *ClientConfig

Copy returns a copy of the configuration.

func (*ClientConfig) Hash

func (c *ClientConfig) Hash() uint32

Hash returns a hash for the configuration.

func (*ClientConfig) URI

func (c *ClientConfig) URI() string

URI returns the URI connection string.

Note that the returned string may differ slightly from the value returned c.Address.URI(). For example, if c.Address omits a port number, an appropriate default port number is used here.

func (*ClientConfig) Validate

func (c *ClientConfig) Validate() error

Validate validates the client configuration, returning an error if there's a problem.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option sets options on a queued server.

func SSLCertAndKey

func SSLCertAndKey(crt []byte, key []byte) Option

SSLCertAndKey adds the given SSL public certificate and private key to the server.

func WithDriver

func WithDriver(d driver.Interface) Option

WithDriver sets the underlying queue system used by the server.

type Server

Server handles client communication.

func NewServer

func NewServer(options ...Option) (*Server, error)

NewServer returns a new queued server.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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