Documentation ¶
Index ¶
- Constants
- Variables
- func AreEqual(c *ClientConfig, d *ClientConfig) bool
- type Client
- func (c *Client) Acknowledge(ctx context.Context, id driver.ID) error
- func (c *Client) Close() error
- func (c *Client) Delete(ctx context.Context, name string) error
- func (c *Client) DriverName() string
- func (c *Client) Get(ctx context.Context, name string) (driver.ID, []byte, time.Time, error)
- func (c *Client) Len(ctx context.Context, name string) (int, error)
- func (c *Client) Put(ctx context.Context, name string, content []byte) error
- func (c *Client) Refresh(ctx context.Context, id driver.ID) (time.Time, error)
- func (c *Client) Requeue(ctx context.Context, id driver.ID) error
- type ClientConfig
- type Option
- type Server
Constants ¶
const ( DefaultTCPPort = 12361 DefaultWSPort = 80 )
The default ports that the queued server listens on.
Variables ¶
var ( ErrNilClient = errors.New("uninitialised client") ErrClosed = errors.New("client is closed") )
errors
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 ¶
Acknowledge removes the message with the given ID from its queue.
func (*Client) DriverName ¶
DriverName returns "pcas queued client".
func (*Client) Get ¶
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 ¶
Len returns the number of messages in the queue with the given name that are not awaiting acknowledgement.
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 ¶
SSLCertAndKey adds the given SSL public certificate and private key to the server.
func WithDriver ¶
WithDriver sets the underlying queue system used by the server.