Documentation
¶
Index ¶
- Variables
- func Bool(reply interface{}, err error) (bool, error)
- func ByteSlices(reply interface{}, err error) ([][]byte, error)
- func Bytes(reply interface{}, err error) ([]byte, error)
- func Float64(reply interface{}, err error) (float64, error)
- func Float64s(reply interface{}, err error) ([]float64, error)
- func Int(reply interface{}, err error) (int, error)
- func Int64(reply interface{}, err error) (int64, error)
- func Int64Map(reply interface{}, err error) (map[string]int64, error)
- func Int64s(reply interface{}, err error) ([]int64, error)
- func IntMap(reply interface{}, err error) (map[string]int, error)
- func Ints(reply interface{}, err error) ([]int, error)
- func String(reply interface{}, err error) (string, error)
- func StringMap(reply interface{}, err error) (map[string]string, error)
- func Strings(reply interface{}, err error) ([]string, error)
- func Uint64(reply interface{}, err error) (uint64, error)
- func Uint64Map(reply interface{}, err error) (map[string]uint64, error)
- func Uint64s(reply interface{}, err error) ([]uint64, error)
- func Values(reply interface{}, err error) ([]interface{}, error)
- type Conn
- type DialOptions
- type Pool
- type PoolOptions
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("closed")
ErrClosed is returned when a Uhaha connection has been closed.
var ErrConnectionTimeout = errors.New("connection timeout")
ErrConnectionTimeout is returned when a conenction to a Uhaha server could not be established within the required time.
var ErrLeadershipTimeout = errors.New("leadership timeout")
ErrLeadershipTimeout is returned when a conenction to a Uhaha leader could not be established within the required time.
var ErrNil = redis.ErrNil
ErrNil indicates that a reply value is nil.
Functions ¶
func Bool ¶
Bool is a helper that converts a command reply to a boolean. If err is not equal to nil, then Bool returns false, err. Otherwise Bool converts the reply to boolean as follows:
Reply type Result integer value != 0, nil bulk string strconv.ParseBool(reply) nil false, ErrNil other false, error
func ByteSlices ¶
ByteSlices is a helper that converts an array command reply to a [][]byte. If err is not equal to nil, then ByteSlices returns nil, err. Nil array items are stay nil. ByteSlices returns an error if an array item is not a bulk string or nil.
func Bytes ¶
Bytes is a helper that converts a command reply to a slice of bytes. If err is not equal to nil, then Bytes returns nil, err. Otherwise Bytes converts the reply to a slice of bytes as follows:
Reply type Result bulk string reply, nil simple string []byte(reply), nil nil nil, ErrNil other nil, error
func Float64 ¶
Float64 is a helper that converts a command reply to 64 bit float. If err is not equal to nil, then Float64 returns 0, err. Otherwise, Float64 converts the reply to an int as follows:
Reply type Result bulk string parsed reply, nil nil 0, ErrNil other 0, error
func Float64s ¶
Float64s is a helper that converts an array command reply to a []float64. If err is not equal to nil, then Float64s returns nil, err. Nil array items are converted to 0 in the output slice. Floats64 returns an error if an array item is not a bulk string or nil.
func Int ¶
Int is a helper that converts a command reply to an integer. If err is not equal to nil, then Int returns 0, err. Otherwise, Int converts the reply to an int as follows:
Reply type Result integer int(reply), nil bulk string parsed reply, nil nil 0, ErrNil other 0, error
func Int64 ¶
Int64 is a helper that converts a command reply to 64 bit integer. If err is not equal to nil, then Int64 returns 0, err. Otherwise, Int64 converts the reply to an int64 as follows:
Reply type Result integer reply, nil bulk string parsed reply, nil nil 0, ErrNil other 0, error
func Int64Map ¶
Int64Map is a helper that converts an array of strings (alternating key, value) into a map[string]int64. The HGETALL commands return replies in this format. Requires an even number of values in result.
func Int64s ¶
Int64s is a helper that converts an array command reply to a []int64. If err is not equal to nil, then Int64s returns nil, err. Nil array items are stay nil. Int64s returns an error if an array item is not a bulk string or nil.
func IntMap ¶
IntMap is a helper that converts an array of strings (alternating key, value) into a map[string]int.
func Ints ¶
Ints is a helper that converts an array command reply to a []in. If err is not equal to nil, then Ints returns nil, err. Nil array items are stay nil. Ints returns an error if an array item is not a bulk string or nil.
func String ¶
String is a helper that converts a command reply to a string. If err is not equal to nil, then String returns "", err. Otherwise String converts the reply to a string as follows:
Reply type Result bulk string string(reply), nil simple string reply, nil nil "", ErrNil other "", error
func StringMap ¶
StringMap is a helper that converts an array of strings (alternating key, value) into a map[string]string. Requires an even number of values in result.
func Strings ¶
Strings is a helper that converts an array command reply to a []string. If err is not equal to nil, then Strings returns nil, err. Nil array items are converted to "" in the output slice. Strings returns an error if an array item is not a bulk string or nil.
func Uint64 ¶
Uint64 is a helper that converts a command reply to 64 bit unsigned integer. If err is not equal to nil, then Uint64 returns 0, err. Otherwise, Uint64 converts the reply to an uint64 as follows:
Reply type Result +integer reply, nil bulk string parsed reply, nil nil 0, ErrNil other 0, error
func Uint64Map ¶
Uint64Map is a helper that converts an array of strings (alternating key, value) into a map[string]uint64. Requires an even number of values in result.
func Uint64s ¶
Uint64s is a helper that converts an array command reply to a []uint64. If err is not equal to nil, then Uint64s returns nil, err. Nil array items are stay nil. Uint64s returns an error if an array item is not a bulk string or nil.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn represents a connection to a Uhaha cluster
func Dial ¶ added in v0.2.0
func Dial(addr string, opts *DialOptions) (*Conn, error)
Dial connects to the Uhaha cluster at the given TCP address using the specified options. The addr param can be a single value or a comma-delimited set of addresses, where the set represents the servers in the Uhaha cluster.
type DialOptions ¶ added in v0.2.0
type DialOptions struct { Auth string // optional TLSConfig *tls.Config // optional ConnectionTimeout time.Duration // default: 5 seconds LeadershipTimeout time.Duration // default: 20 seconds }
DialOptions ...
type Pool ¶ added in v0.2.0
type Pool struct {
// contains filtered or unexported fields
}
Pool represents a Uhaha connection pool
func NewPool ¶ added in v0.2.0
func NewPool(opts PoolOptions) *Pool
NewPool returns a new Uhaha pool
type PoolOptions ¶ added in v0.2.0
type PoolOptions struct { DialOptions // The Dial Options for each connection InitialServers []string // The initial cluster server addresses PoolSize int // Max number of connection in pool. default: 15 }
PoolOptions are provide to NewPool.