client

package
v0.0.0-...-9f8e559 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2016 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTimeout is returned if a read times out.
	ErrTimeout = errors.New("timeout")
	// ErrMissing is returned if a value is requested without allowing for a
	// timeout.
	ErrMissing = errors.New("missing")
)

Functions

This section is empty.

Types

type Client

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

Client holds all the state necessary for interacting with a counterd server.

func Dial

func Dial(addr string) (*Client, error)

Dial connects to a counterd service at a specified address.

func (*Client) Close

func (c *Client) Close() error

Close closes the client.

func (*Client) Increment

func (c *Client) Increment(k uint64, v float64, t time.Duration) error

Increment adds a (potentially negative) value to a counter on the server, scheduled to be reverted after a certain duration.

func (*Client) IncrementString

func (c *Client) IncrementString(k string, v float64, t time.Duration) error

IncrementString is like Increment, but uses the FNV hash of a string as the key.

func (*Client) Monitor

func (c *Client) Monitor(ch chan KV)

Monitor registers a channel to receive updates when a notification comes in from the counterd server.

func (*Client) Read

func (c *Client) Read(k uint64) (float64, error)

Read returns what the client has cached locally for a particular key, or ErrMissing if there's no cached value.

func (*Client) ReadOrQuery

func (c *Client) ReadOrQuery(k uint64, t time.Duration) (float64, error)

ReadOrQuery does what it sounds like it does. It either returns the locally cached value of a particular key, or it makes a request to the server.

func (*Client) ReadOrQueryString

func (c *Client) ReadOrQueryString(k string, t time.Duration) (float64, error)

ReadOrQueryString is like ReadOrQuery, but uses the FNV hash of a string as the key.

func (*Client) ReadString

func (c *Client) ReadString(k string) (float64, error)

ReadString is like Read, but uses the FNV hash of a string as the key.

func (*Client) Subscribe

func (c *Client) Subscribe(k uint64) error

Subscribe makes a request to the server to begin sending update notifications for a particular key.

func (*Client) SubscribeString

func (c *Client) SubscribeString(k string) error

SubscribeString is like Subscribe, but uses the FNV hash of a string as the key.

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(k uint64) error

Unsubscribe makes a request to the server to stop sending update notifications for a particular key.

func (*Client) UnsubscribeString

func (c *Client) UnsubscribeString(k string) error

UnsubscribeString is like Unsubscribe, but uses the FNV hash of a string as the key.

type KV

type KV struct {
	K uint64
	V float64
}

KV represents a key/value pair.

Jump to

Keyboard shortcuts

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